Column not found: 1054 :Unknown column 'employee' in 'field list' in MySQL when use nova-repeatable-fields - laravel-nova

I use nova-repeatable-fields package for add more functionality. When I save data, "Unknown column 'employees' in 'field list'" error comes. employee field is not in database. My code like this:
Repeater::make('Employees')
->addField([
'label' => 'Full name',
'name' => 'full_name',
'type' => 'text',
'placeholder' => 'Full Name',
])
->addField([
'label' => 'ID No',
'name' => 'id_no',
'type' => 'text',
'placeholder' => 'ID No',
])
->addButtonText('Add')
->displayStackedForm(),
Please show image for better understand

Related

caxlsx_rails autoselect the first element of a dropdown

I am making use of the caxlsx_rails gem, and I am adding this dropdown:
sheet.add_data_validation("F6:F2000", {
:type => :list,
:formula1 => "=IFERROR(VLOOKUP(E6,Lista_de_novedades_disponibles!A$2:B$#{#select_novedades['novelty'].count+1},2,0),#{'"n/a"'})",
:showDropDown => false,
:showErrorMessage => true,
:errorTitle => '',
:error => 'Please use the dropdown selector to choose the value',
:errorStyle => :stop,
:showInputMessage => true,
:prompt => 'Choose the value from the dropdown'
})
but I need the first item to be automatically selected without the user having to select it. is this possible?

Zend Framework 2 form radiobutton rendering exception

I have the following problem.
I have a ZF2 (Version 2.5.1) form including this:
// Gender
$this->add(array(
'name' => 'gender',
'type' => 'radio',
'options' => array(
'label' => 'Gender',
'value_options' => array(
'1' => 'Male',
'2' => 'Female'
)
)
));
And attempting to render it in a view like this:
echo "<div>";
echo $this->formLabel($form->get('gender')) . "\n";
echo $this->formRow($form->get('gender'));
echo "</div>";
Which gives me the following exception (thrown via the call to formRow):
Zend\Form\View\Helper\FormMultiCheckbox::render requires that the element is of type Zend\Form\Element\MultiCheckbox
With the exception being thrown at line #103 in the file zend-form\src\View\Helper\FormMultiCheckbox.php.
Is there anyone else that have had this problem? Am I doing something horribly wrong here?
Thanks in advance.

zf2 default validation messages not overriding

$inputFilter->add(array(
'name' => 'nightCharges',
'required' => FALSE,
'filters' => array(
array('name' => 'Digits'),
),
'validators' => array(
array(
'name' => 'GreaterThan',
'options' => array(
'min' => 1,
'messages' => array(
\Zend\Validator\GreaterThan::NOT_GREATER => 'My message',
),
),
),
),
));
Above is my code snippet for validation in this case for 'check box'. If I set 'required' to "true" and submit empty form, it shows me the default 'Value is required and can't be empty' message and if I set 'required' to 'false' it does't show me any error at all. Even if I submit non digit value it doesn't show me actual error message.
Where am I making mistake?
Actually I was working on 'Please accept the terms & conditions' check box.
Rather than using the GreaterThan validator, try using Identical to ensure the value can't be anything other than 1.
'validators' => array(
array(
'name' => 'Identical',
'options' => array(
'token' => '1',
'messages' => array(
Identical::NOT_SAME => 'Please accept the terms & conditions.',
),
),
),
),

zf2 formFilter regex howto

Using zendframework v2, I have run into a problem with a regex validator on a field created by the Form factory. All other fields (using the same pattern) work without a problem.
Any tips, or pointers is appreciated.
$inputFilter->add($factory->createInput([
'name' => 'organizationName',
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'NotEmpty',
'options' => array(
'messages' => array(
\Zend\Validator\NotEmpty::IS_EMPTY => 'Organization name field is empty',
),
),
),
array(
'name' => 'Regex',
'options' => array(
'pattern' => '/^[a-z0-9 &-_\.,#]{3,25}$/i',
'messages' => array(
\Zend\Validator\Regex::INVALID => 'Invalid input, only a-z, 0-9 & - _ . characters allowed',
),
),
),
array (
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => '2',
'max' => '25',
'messages' => array(
\Zend\Validator\StringLength::TOO_SHORT => 'Organization name field must be at least 8 characters in length',
\Zend\Validator\StringLength::TOO_LONG => 'Organization name field must be no longer than 25 characters in length',
),
),
),
),
]));
Additional details:
I am using the ZF2 to generate a form, I also create a validation filter and then use the controller to handle proper form submissions.
The problem I am having is with the above inputFilter object that handles the "organizationName" regex filter.
It seems that although the regex patter I use both in the form definition and the input filter of [a-z0-9 &-_.,#]{3,25} does not handle the string Intl. Widgets Inc. even though I do not get an error message from $form->getMessages() etc.
Color me stumpted
That's because your regexp does match Intl. Widgets Inc. : http://rubular.com/r/oPbk2cdarB

Zend Framework 2: Trying to add a selectbox to a form does not render values

I am trying to add a selectbox to one of my forms (which just with input type="text" elements are working pretty good) but all I get is just an empty selectbox with none tags in it. So this is the code I use:
Bla.php :: Bla->getInputFilter()
$inputFilter->add($factory->createInput(array(
'type' => 'Zend\InputFilter\Select',
'name' => 'payment_type',
'required' => true,
'filters' => array(
array('name' => 'Int'),
),
)));
BlaForm.php :: BlaForm->__construct():
$this->add(array(
'type' => 'Zend\Form\Element\Select',
'name' => 'payment_type',
'options' => array(
'label' => 'Payment',
'value_options' => array(
0 => 'Nur Überweisung',
1 => 'Nur Paypal',
2 => 'Nur Barzahlung im Voraus',
),
),
'attributes' => array(
'value' => 0 //set selected to "Nur Überweisung"
)
));
bla.php (View)
<div class="control-group">
<?php
echo $this->formLabel($form->get('payment_type')->setLabelAttributes(array(
'class' => 'control-label'
)));
?>
<div class="controls">
<?=$this->formElement($form->get('payment_type'));?>
<span class="help-inline"><?=$this->formElementErrors($form->get('payment_type'));?></span>
</div>
</div>
I already tried using "options" instead of "value_options" and yesterday I learned that it is just an alias of "value_options". Also I tried formSelect() instead of formElement() in my view but that doesn't change anything either. I even removed the umlauts from the strings for testing purposes...
Did anybody experience the same problem or has any idea, what I am currently doing wrong?
I just tried your examples locally against current master (rev 9747bd01d), and they worked without issue -- using either formCollection() on the form, or formElement() or formSelect() on the individual element. In each case, I get the following markup:
<select name="payment_type"><option value="0" selected="selected">Nur Überweisung</option>
<option value="1">Nur Paypal</option>
<option value="2">Nur Barzahlung im Voraus</option></select>
What version of ZF2 are you using? Can you test against either 2.0.2 or current master, please?
I found the solution myself. In BlaForm.php the format of the selectbox element has to be as follows:
$this->add(array(
'type' => 'Zend\Form\Element\Select',
'name' => 'payment_type',
'options' => array(
'label' => 'Bezahlung',
),
'attributes' => array(
'options' => array(
0 => 'Nurerweisung',
1 => 'NurPaypal',
2 => 'NurBarzahlung im Voraus',
3 => 'NurBarzahlung am Bus',
),
'value' => 2 //set selected to "public"
)
));
The "options" and "value" need to be nested unter "attributes"... well yeah, why not? I found out by looking deeper inter Zend\Form\Element\Select where a method "getOptionAttributeValues()" exists, which gave me the hint.

Resources