示例#1
0
 /**
  * Convert an array of attributes into valid HTML.
  * @param string[] $attributes Attributes, see {@see Html::readAttributes}.
  * @return string Attributes
  */
 public function addAttributes($attributes)
 {
     $output = '';
     $attributes = Html::readAttributes($attributes);
     foreach ($attributes as $name => $value) {
         if (is_string($value) or $value === true) {
             $output .= ' ' . $name;
             if ($value !== true) {
                 $output .= '="' . h($value) . '"';
             }
         }
     }
     return $output;
 }
示例#2
0
 /**
  * Output a submit button.
  * @param string $label Button label.
  * @param string|string[] $attributes Attributes, see
  * {@see Html::readAttributes}.
  * @return string HTML submit element.
  */
 public function submit($label, $attributes = array())
 {
     $button = $this->Html->create('input', 'type=submit');
     $button->attr('value', $label);
     $button->attr(Html::readAttributes($attributes));
     return $button->toString();
 }