Example #1
0
File: Set.php Project: skema/skema
 public function eachJSON($fn)
 {
     $this->each($fn, function ($directive) {
         $result = Type::Directive($directive)->renderJSON();
         return $result;
     });
     return $this;
 }
Example #2
-1
 public function renderHTMLInput()
 {
     $template = $this->field->htmlInputTemplate;
     $options = '';
     $this->field->eachOption(function ($directives, $recordID) use(&$options, $template) {
         $optionText = Utility::mustachify($template, function ($match) use($directives, $recordID) {
             if (isset($directives[$match])) {
                 return Type::Directive($directives[$match])->renderPlain();
             } else {
                 if ($match === 'key') {
                     return $recordID;
                 }
             }
             return '';
         });
         $optionTextEncoded = htmlentities($optionText);
         $selected = $this->value == $recordID ? ' selected="selected"' : '';
         $options .= "<option value='{$recordID}'{$selected}>{$optionTextEncoded}</option>";
     });
     $key = $this->key();
     return "<select name='{$key}'>{$options}</select>";
 }