i am using below code:-
echo $this->Form->input('my_radio',array(
'label' =>false,
'type' => 'select',
'multiple' => 'checkbox',
'class'=>'checkbox12',
'div'=>false,
'selected' => array_keys($sub_cat_name1),
'options' => $parent_cat_detail1
));
i did false the div but still the 'checkbox12' is adding to div.
the problem is not in the class , is in the mutiple value , you should put it true not checkbox :
echo $this->Form->input('my_radio',array(
'label' =>false,
'type' => 'select',
'multiple' => true,
'class'=>'checkbox12',
'selected' => array_keys($sub_cat_name1),
'options' => $parent_cat_detail1
));
Related
echo $this->Form->input('product_id', array(
'label'=>false,
'type'=>'select',
'multiple'=>'checkbox',
'options'=>$product,
));
I am trying to adding 'checked=>true' in from input but failed
this is screenshoot of the form edit, the data already selected is not checked
You can tell CakePHP which checkboxes are checked by passing an array of selected values:-
$selected = []; // An array of selected values
echo $this->Form->input('product_id', array(
'label' => false,
'type' => 'select',
'multiple' => 'checkbox',
'options' => $product,
'selected' => $selected
));
If you wanted to select all the values to start with you could pass the array keys of $product to the selected option:-
$selected = array_keys($product);
echo $this->Form->input('product_id', array(
'label' => false,
'type' => 'select',
'multiple' => 'checkbox',
'options' => $product,
'selected' => $selected
));
I am using cakephp3 and select2 dropdown script.
My call to the data looks like this
$roles = $this->ParticipantsProjectsRoles->Roles->find('list', [
'keyField' => 'id',
'valueField' => 'description'
]);
within my view I call this
<?=$this->Form->input('role_id', ['options' => $roles, 'label' => false, 'class' => 'form-control select2me']);?>
The output HTML will load always the first data entry into the select.
Is there a way to have the first value always empty?
Set the empty key in the options array to true or another value, e.g. Select Role:
$this->Form->input(
'role_id', [
'options' => $roles,
'label' => false,
'class' => 'form-control select2me',
'empty' => true
]
);
I want to set a default 'selected' for my checkbox in zend 2.
i tried adding a default
'value'=>'selected'
but it does not seem to work.
$this->add(array(
'type' => 'Zend\Form\Element\Checkbox',
'name' => 'receiveNewsletters',
'options' => array(
'value_options' => array(
'1' => 'Untick if you do not want to receive promotional emails',
),
'attributes' => array(
'value'=>'selected',
),
),
));
The value should be the checked_value. By default it is '1'
$this->add(array(
'type' => 'Zend\Form\Element\Checkbox',
'name' => 'receiveNewsletters',
'options' => array(
'label' => 'Untick if you do not want to receive promotional emails',
),
'attributes' => array(
'value' => '1',
),
));
I have built a form using the CakePHP form helper and I am trying to get it to change my users password, that should not be to hard. But for some reason when I submit the form it submits in plan text.
$UsersPass = $this->Form->create('PasswordUpdate', array('id' => 'ChangePassword', 'url' => '/update_password'));
$UsersPass .= $this->Form->input('oldpassword', array('div' => false, 'type' => 'password', 'label' => 'Old Password'));
$UsersPass .= $this->Form->input('passwordnew', array('div' => false, 'type' => 'password', 'label' => 'New Password'));
$UsersPass .= $this->Form->input('passwordconfirm', array('div' => false, 'type' => 'password', 'label' => 'Confirm'))l
$UsersPass .= $this->Form->submit(' ', array('div' => false, 'type' => 'submit', 'class' => 'Button_DoneSubmit') );
echo UsersPass;
Any way of getting CakePHP to make sure that it does not submit in plan text?
thanks.
I add the checkbox functionality from the yii-booster. But the widget renders the model view without the needed boxes. What's wrong?
Widjet code in view
<?php
$this->widget('bootstrap.widgets.TbExtendedGridView',array(
'id'=>'docs-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'type'=>'bordered condensed',
'template' => "{items}",
'bulkActions' => array(
'actionButtons' => array(
array(
'buttonType' => 'button',
'type' => 'primary',
'size' => 'small',
'label' => 'Choose',
'click' => 'js:function(values){console.log(values);}'
)
),
// if grid doesn't have a checkbox column type, it will attach
// one and this configuration will be part of it
'checkBoxColumnConfig' => array(
'name' => 'id'
),
),
));
If you are using bulkActions, you have to use 'columns' to list out the columns you want to display instead of using 'template'.
'columns' => array(
'id',
'title',
...
),
the problem has been in the wrong hierarchy from the example:
The 'checkBoxColumnConfig' attribute must be outside of the 'actionButtons' attribute:
'bulkActions' => array(
'actionButtons' => array(
/*array(
'buttonType' => 'button',
'type' => 'primary',
'size' => 'small',
'label' => 'Выбрать отмеченные',
'click' => 'js:function(values){console.log(values);}'
)
),*/
// if grid doesn't have a checkbox column type, it will attach
// one and this configuration will be part of it
),
'checkBoxColumnConfig' => array(
'name' => 'id'
),
...
));
but now the widget doesn't work when i uncomment the array part inside 'actionButtons':
array(
'buttonType' => 'button',
'type' => 'primary',
'size' => 'small',
'label' => 'Выбрать отмеченные',
'click' => 'js:function(values){console.log(values);}'
)
what might be a cause?