TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Formo 2.0 Available
  • I'm pleased to announce the general availability of Formo 2.0 for Kohana 3.2.

    Get it at Github: https://github.com/bmidget/kohana-formo

    Create form objects, validate 'em, render 'em, do all sorts of stuff with 'em. Formo makes working with forms a breeze.

    Please report issues on Github.

    Notable Features:

    • Plays well with Kohana ORM
    • Plays well with Gacella ORM
    • Use templates, vanilla html or auto-gen your forms
    • Aid your html5 transition with html5 input type support
    • Forms, subforms, fields
    • Driver-based and extendable

    Hope you enjoy it. Word.

  • Congratulations for this step. I really like formo

  • Welcome

    ** Please advice. **

    How to change the display name group of subform?.

    Always as the title of the form shows the name of the form.

    return Formo::form(array('label'=>'Formularz'))
    ->add('product', 'group', $product_form)
    ->add('Zapisz','submit');

    eg change 'product' to labelled 'Produkty finalne' etc...

    regards
    ** Kmicic **
  • File a bug report on github
  • This is not bug, please info about what change in code for formo group subform title (label).
    screenshot on : http://img822.imageshack.us/img822/6985/changelabel.png
    eg 'page' to 'my first page' ... (not changed group name, only changed display label)

    ``$mainform = Formo::form()
    ->add('article', 'group', $articleform)
    ->add('page', 'group', $pageform)
    ->add('Zachowaj','submit','Zachowaj zmiany',array('css'=>array('width'=>'200px')))
    ->add('AddPage','submit','Dodaj stronę',array('css'=>array('width'=>'200px')));``

    regards
    AK
  • you've convinced me, I'm using it in my next project :D

  • @kmicic In latest commit to Formo, the header in the Group view file properly uses label instead of just the field's alias.

    Thus, your example of manually setting the label would work.

    Another way to change the label would be to turn on the use_messages config flag and use Kohana's messages to set a name for that group's alias.

  • I'm sorry that I am your valuable time. But what I do not want to work well.

           $mainform = Formo::form()
               ->add('newsletter', 'group', $newsletterform,array('label' => 'Site NewsLetter','text'=>'Site NewsLetter',))
               ->add('Save','submit','Save changes')
               ->add(array('alias'=>'AddQueque','driver'=>'button','text'=>'Add to Queque'))
               ->add(array('alias'=>'DelQueque','driver'=>'button','text'=>'Del from Queque'));
    
            $this->template->content[]=View::factory('template/modnews')
               ->set('display','block')
               ->set('bam_head','Edit for :' . $mainform->newsletter->tx_subject->val())
               ->set('bam_content', $mainform->render());
    
            if ($mainform->load()->validate()) { 
                if (isset($_POST['form']['DelQueque'])) 
                   $this->request->redirect('newsletter/drop/'.$_POST['newsletter']['tx_id']);
                   //redirect for confirm deletion
                elseif (isset($_POST['form']['AddQueque'])) 
                   $newsletter_model->add_queque($_POST['newsletter']);
                else   
                   $newsletter_model->update_newsletter($_POST['newsletter']);
    
                $this->request->redirect('newsletter/index');
                }
        }
    

    Alias ​​is needed to separate forms for $_POST variable but I would like to display a label instead of the alias.

               ->add('newsletter', 'group', $newsletterform,array('label' => 'Site NewsLetter','text'=>'Site NewsLetter',))
    

    this structure for insert label as 'Site NewsLetter' does not work?.

    change in the view fragment displayed subform label, from :

    ` echo str_replace('_', ' ', $this->alias()); `
    

    to

    ` echo str_replace('_', ' ', $this->label()); `
    

    and then is displayed:

    of: form.newsletter ???

    help me please !. And sorry for my english :( AK

  • Hey Benjamin,

    is it possible to quickly add some html in a form? something like

     $formo->add_html('some_extra_div_before_an_input'); 
    
  • I guess you can not do, or do not know how to do it?. This option would be very useful. Separation subform sign, a different style, etc. Since simply deleting the underscore is only a temporary solution and enables the use only of ANSI characters. An alias is used in the variable $_POST and can not enabled to contains nationals characters.

    You Think to supplement the add command for groups subforms with a possibility subform pass options "label".

    that such a structure also acted as the title subview named 'group':

     -> add (alias, "group", subform, array ('label' => 'Grzegżółka'))  
    
  • Okay, found how to generate html by rendering individual fields: $form->$fieldname->generate();

  • What would be handy is if the 'label' attribute would be set to false, no label would be generated. or a function that would only display the field, like $form->email_field->render_field_only();

  • Owkay, now I feel really stupid (again). Can someone remove my comments? :p Formo2.0 got all that stuff... $form->fieldname->view()->html();

  • Problem solved by using base64 encoding to a group alias, then you can use any national characters in the titles of group forms. for create group :

    $mainform = Formo::form() ->add (base64_encode('Edycja kategorii :'.$model_result[0]['category_name']),'group',$category_form) ->add('Zachowaj','submit','Zachowaj zmiany');

    for view :

    echo base64_decode($this->alias());

    regards kmicic

  • However, please note that is sent to all fields _POST variable with the key in base64 encoded. example for 4 subform groups: if ($mainform->load()->validate()) { // merge all post $post=array_merge($_POST[base64encode('Szczepana Brzęczyszczykiewicza dane')], $_POST[base64encode('Adres Chrząszczykowice Szczecińskie')], $_POST[base64encode('Gmina Gołowody')], $_POST[base64encode('Stół z powyłamywanymi nogami')]); ... update ... }

  • @kmicic Seems like an awful lot of overhead for a field alias. You'd be much better off using latin characters for the alias, and use the special characters as a 'label' param

  • @benjamin I know it looks terrible. I resigned because of the use Formo subform title display without of national characters an alias is not a good solution. Label as the title subform also does not work. It is a pity because this is a good module. regards AK

  • I love this module, been using Formo since 2009!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion