About CoralsForm::checkbox once checked, value can not be updated to unchecked

Laraship QuestionsCategory: TechnicalAbout CoralsForm::checkbox once checked, value can not be updated to unchecked
jedjie asked 5 years ago

Hello,

I would like to know how can I update a value that once checked can not be updated to uncheck anymore. What should be done, if there is the case I am missing something. Thank you in advance. Tia.

here is my standard implementation

CoralsForm::checkbox ('done', 'Resource::attributes.reader.done', $reader->done)

1 Answers
Best Answer
laraship Staff answered 5 years ago

Hello,

You need to handle that in the Request file, because after 5.5 if the input field is empty its not passed to the middleware

for example in PostRequest you will find the below command

public function getValidatorInstance()

{

$data = $this->all();

if (isset($data['slug'])) {

$data['slug'] = str_slug($data['slug']);

}

$data['published'] = array_get($data, 'published', false);

$data['private'] = array_get($data, 'private', false);

$data['internal'] = array_get($data, 'internal', false);

$this->getInputSource()->replace($data);

return parent::getValidatorInstance();

}

jedjie replied 5 years ago

It figures now, nice code, I will give it try, and thank you very much! 😀

jedjie replied 5 years ago

Its working now, thumbs up! thank you!

laraship Staff replied 5 years ago

🙂