From: Andrey Kutejko Date: Sun, 8 Feb 2015 15:50:13 +0000 (+0200) Subject: extra attrs for widget and label X-Git-Tag: 0.6~57 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=7516b6772390226d61e168564b883a0f2429dc00;p=ipf.git extra attrs for widget and label --- diff --git a/ipf/form/boundfield.php b/ipf/form/boundfield.php index f997d3d..41defe2 100644 --- a/ipf/form/boundfield.php +++ b/ipf/form/boundfield.php @@ -42,14 +42,12 @@ class IPF_Form_BoundField return $this->form->initial($this->name); } - public function renderWidget() + public function renderWidget($extra_attrs=array()) { $widget = $this->field->widget; - $extra_attrs = array(); - if (!array_key_exists('id', $widget->attrs)) { + if (!array_key_exists('id', $widget->attrs)) $extra_attrs['id'] = $this->autoId(); - } if ($widget->embeds_errors) $extra_attrs['errors'] = $this->errors; @@ -65,9 +63,10 @@ class IPF_Form_BoundField return IPF_Form::renderErrorsAsHTML($this->errors); } - public function renderLabel() + public function renderLabel($extra_attrs=array()) { $label = Tag::label() + ->attrs($extra_attrs) ->append($this->label); $widget = $this->field->widget;