I have custom module for admin where in block there is form. I want to set dynamic value to input type="text" but not able to set. Please, see my snippet below:
$fieldset->addField(
'category_code', 'text', ['name' => 'category_code','value'=>'11', 'label' => __('Category Code'), 'title' => __('Category Code'), 'required' => true]
);
}else{
$fieldset->addField(
'category_code', 'text',['name' => 'category_code1',
'value'=> $this->vendorAutoCode(),
'label' => __('Category Code'), 'title' => __('Category Code'), 'required' => true]
);
}
public function vendorAutoCode(){
//str_pad(rand(0,9999), 5, "0", STR_PAD_LEFT);
return str_pad(rand(0,9999), 5, "0", STR_PAD_LEFT);
}