Esempio n. 1
0
 /**
  * Register the service provider.
  *
  * @return \Lionart\Edifice\Form\Edifice
  */
 public function register()
 {
     $this->app['edifice.form'] = $this->app->share(function ($app) {
         $edifice = new EdificeFormBuilder($app['form']);
         $edifice->setConfig($app['config']->get('edifice::edifice'));
         return $edifice->setSessionStore($app['session']);
     });
 }
Esempio n. 2
0
 /**
  * Processes a HTML input with its label.
  *
  * @todo  errors should not be delegated to edifice, but edifice should give them to the input
  * @fixme inline label creation : should add columns ratio for Foundation CSS Styling
  *
  * @param       $name
  * @param       $tag
  * @param array $additions
  *
  * @return string
  */
 protected function process($name, $tag, $additions = array())
 {
     // Extracted variables are label, prefix and postfix
     extract($additions);
     $has_error = false;
     $error_message = '';
     $errors = $this->edifice->getErrors($name);
     if (sizeof($errors) > 0) {
         $has_error = true;
         $error_message = $this->getErrorElement($errors);
     }
     $result = $this->openRow($has_error, isset($prefix), isset($postfix));
     if (isset($label['label'])) {
         if (isset($label['inline']) and $label['inline'] === true) {
             // Inline label creation
             $input_tag = create_div(array('class' => 'small-8 large-8 columns'), $tag . $error_message);
             $result .= $label['label'] . $input_tag . $this->closeRow();
         } else {
             // Label is top of input
             $result .= $label['label'] . $tag . $this->closeRow();
         }
     } elseif (isset($prefix) || isset($postfix)) {
         if (isset($prefix)) {
             $input_tag = create_div(array('class' => 'small-8 large-8 columns'), $tag . $error_message);
             $result .= $prefix . $input_tag;
         }
         if (isset($postfix)) {
             $input_tag = create_div(array('class' => 'small-8 large-8 columns'), $tag . $error_message);
             $result .= $input_tag . $postfix;
         }
         $result .= $this->closeRow();
     } else {
         $result .= $tag . $error_message . $this->closeRow();
     }
     return $result;
 }