Calcio
(Cálcio)
July 3, 2015, 4:45pm
1
Hi guys
When I use a hidden field created by Yii, it include a new blank line and brake a grid layout on my View. Is it occur with you too?
Bizley
(Bizley)
July 3, 2015, 4:55pm
2
How do you insert it in your view?
Calcio
(Cálcio)
July 3, 2015, 5:19pm
3
@Bizley I’m trying it.
<?= $form->field($model, 'name')->hiddenInput()->label('') ?>
Other bug that I noticed is the label always appears. So I need put the ->label(’’) to hide it to.
Bizley
(Bizley)
July 3, 2015, 7:32pm
4
I’ve checked it and this is how it should be done:
To remove label you should use
->label(false)
Method \yii\widgets\ActiveField::hiddenInput() is provided only for completeness. Because there is no need to validate such field in most cases you should use
\yii\helpers\Html::activeHiddenInput()
* @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]].
*
* If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly.
*
* @return $this the field object itself.
*/
public function input($type, $options = [])
{
$options = array_merge($this->inputOptions, $options);
if ($this->form->validationStateOn === ActiveForm::VALIDATION_STATE_ON_INPUT) {
$this->addErrorClassIfNeeded($options);
}
$this->addAriaAttributes($options);
$this->adjustLabelFor($options);
$this->parts['{input}'] = Html::activeInput($type, $this->model, $this->attribute, $options);
return $this;
}
Calcio
(Cálcio)
July 4, 2015, 12:50am
5
Thanks @Bizley , I’ll chek it.