Beispiel #1
0
 /**
  * Construct.
  *
  * @param \Widget    $widget    The form widget.
  * @param \FormModel $formModel Optional the corresponding form model.
  */
 public function __construct(\Widget $widget, \FormModel $formModel = null)
 {
     $this->widget = $widget;
     $this->formModel = $formModel;
     $this->attributes = new Attributes();
     $this->container = new Container();
     $this->label = new Label();
     $this->errors = new Errors($widget->getErrors());
     $this->widgetType = WidgetUtil::getType($widget);
 }
 /**
  * Transform widget attributes to element attributes.
  *
  * @param \Widget $widget  The form widget.
  * @param Element $element The widget element.
  *
  * @return void
  */
 public function transformAttributes($widget, Element $element)
 {
     $attributes = Widget::getAttributes($widget);
     $attributes = array_filter($attributes);
     if ($element instanceof MultipleValues && $element->isElementCollection()) {
         $element->getChildAttributes()->addAttributes($attributes);
     } else {
         $element->addAttributes($attributes);
     }
 }