コード例 #1
0
ファイル: FileWidget.php プロジェクト: crabstudio/app
 /**
  * Render a file upload form widget.
  *
  * Data supports the following keys:
  *
  * - `name` - Set the input name.
  * - `escape` - Set to false to disable HTML escaping.
  *
  * All other keys will be converted into HTML attributes.
  * Unlike other input objects the `val` property will be specifically
  * ignored.
  *
  * @param array $data The data to build a file input with.
  * @param \Cake\View\Form\ContextInterface $context The current form context.
  * @return string HTML elements.
  */
 public function render(array $data, ContextInterface $context)
 {
     $data += ['name' => '', 'id' => '', 'val' => null, 'type' => 'text', 'escape' => true, 'templateVars' => []];
     $data['value'] = $data['val'];
     unset($data['val']);
     return $this->_templates->format('file', ['name' => $data['name'], 'id' => str_to_slug($data['name']), 'type' => $data['type'], 'templateVars' => $data['templateVars'], 'attrs' => $this->_templates->formatAttributes($data, ['name', 'type'])]);
 }
コード例 #2
0
ファイル: strings.class.php プロジェクト: tfont/skyfire
 protected function str_to_slug($text, $strict = FALSE)
 {
     if (defined('STRICT_TYPES') && CAMEL_CASE == '1') {
         return (string) self::parameters(['text' => DT::STRING, 'strict' => DT::BOOL])->call(__FUNCTION__)->with($text, $strict)->returning(DT::STRING);
     } else {
         return (string) str_to_slug($text, $strict);
     }
 }