<i><span class="comment"> // Example Checkbox</span>
<span class="variable"> $ops</span> = <span class="keyword">array</span>(<span class="string">'male'</span>, <span class="string">'female'</span>);
<span class="variable"> $form</span>->add(<span class="string">'gender'</span>, <span class="string">''</span>, <span class="keyword">array</span>(<span class="string">'options'</span> => <span class="variable">$ops</span>, <span class="string">'type'</span> => <span class="string">'checkbox'</span>, <span class="string">'value'</span> => <span class="string">'true'</span>));
</i><br>When it appears to just render multiple checkboxes?<br><br>Anyone have any examples/references where I can achieve a normal single checkbox with value=1 if checked, else its unchecked?<br>
// do we have input?The 'default' value in the ORM property definition is only used when you forge a new model instance, and you don't pass the field in the data array. It won't reset columns to a default value. If you don't pass a value on update, the ORM assumes (rightly) that you don't want to alter that columns value.
if (\Input::post())
{
// validate the input
$form->validation()->run();
// if validated, save the updates
if ( ! $form->validation()->error())
{
// get the validated data, and get rid of null values
$data = array_filter($form->validated(), function($item){ return $item !== null; });
// do something about invalid or missing values
empty($data['birthdate']) and $data['birthdate'] = null;
empty($data['dyslectic']) and $data['dyslectic'] = 0;
// update the person record
$people->from_array($data);
// and save it
if ($people->save())
{
\Messages::success(sprintf(__('people.updated'), $people->surname.', '.$people->initials.' '.$people->prefix));
\Pagelink::redirect_back($people) or \Response::redirect('module/people/'.$people->type);
}
else
{
\Messages::error(__('people.updated-failed'));
}
}
else
{
// inform the user validation failed
\Messages::error(__('people.form.errors'));
}
// repopulate the form from the posted data
$form->repopulate();
}
It looks like you're new here. If you want to get involved, click one of these buttons!