yii2-bootstrap4
yii2-bootstrap4 copied to clipboard
ActiveField::staticControl inputOptions
Missing inputOptions in \yii\bootstrap4\ActiveField::staticControl
public function staticControl($options = [])
{
+ $options = array_merge($this->inputOptions, $options);
$this->adjustLabelFor($options);
$this->parts['{input}'] = Html::activeStaticControl($this->model, $this->attribute, $options);
return $this;
}
Yii version - 2.0.23 yiisoft/yii2-bootstrap4 - 2.0.6
Thanks for posting in our issue tracker. In order to properly assist you, we need additional information:
- When does the issue occur?
- What do you see?
- What was the expected result?
- Can you supply us with a stacktrace? (optional)
- Do you have exact code to reproduce it? Maybe a PHPUnit tests that fails? (optional)
Thanks!
This is an automated comment, triggered by adding the label status:need more info.
The ActiveField::staticControl method lost values of ActiveField::inputOptions.
This cause problem, for example we have an ActiveField:
$field = $form->field($model, $attribute, [
'inputOptions' => ['class' => 'my-class']
]);
But when rendering it lost inputOptions:
echo $field->staticControl();
All other similar methods of \yii\widget\ActiveField has that behavior:
public function input($type, $options = [])
{
$options = array_merge($this->inputOptions, $options);
public function textInput($options = [])
{
$options = array_merge($this->inputOptions, $options);
public function hiddenInput($options = [])
{
$options = array_merge($this->inputOptions, $options);
public function passwordInput($options = [])
{
$options = array_merge($this->inputOptions, $options);
public function fileInput($options = [])
{
if ($this->inputOptions !== ['class' => 'form-control']) {
$options = array_merge($this->inputOptions, $options);
public function textarea($options = [])
{
$options = array_merge($this->inputOptions, $options);
and so on ... So, staticControl() must not lost values, configured in inputOptions too. It's a bug.
Similar issue for other methods: https://github.com/yiisoft/yii2/issues/17374
I don't think it makes sense to copy the general "input options" to static control too. It has other classes and properties: https://getbootstrap.com/docs/4.3/components/forms/#readonly-plain-text
I don't think it makes sense to copy the general "input options" to static control too. It has other
For what other purposes and scenarios is this field intended and can be used? ActiveField renderer only by one of methods - textField or staticField or anothe. ActiveField instance not using many times with different input rendering. So, all it data intended to be used just for one purpose - rendering field. I'm usng ActiveField in my library and all workng fine except the staticControl, which, unlike other methods, loses and does not take into account the parameters. This is an obvious bug.
Other properties (like readonly="true") must be added to options by staticControl, as other method does.
No the static control is not like other fields. It's not just the readonly property, it has other classes and just exists in bootstrap library because it just exists in bootstrap framework. It makes no sense to copy all the options from default inputs and have to unset them in the staticControl method again...