]> git.andy128k.dev Git - ipf.git/commitdiff
extra attrs for widget and label
authorAndrey Kutejko <andy128k@gmail.com>
Sun, 8 Feb 2015 15:50:13 +0000 (17:50 +0200)
committerAndrey Kutejko <andy128k@gmail.com>
Sun, 8 Feb 2015 15:59:22 +0000 (17:59 +0200)
ipf/form/boundfield.php

index f997d3d2a0c438a34bbc6d5a6de2633183536f76..41defe2a654212e791234d163d404219db922bbf 100644 (file)
@@ -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;