Welcome Guest, Not a member yet? Register   Sign In
Rabbit Forms Beta 1.0.5

[eluser]freshface[/eluser]
I cant get the filters to work.

It is this line:

Code:
filters:
        -nieuwsbrief_group_id = 3

This is my yaml file:

Code:
table: nieuwsbrief
fields:
    naam:
        type: TextBox
        label: Naam
    email:
        type: TextBox
        label: Email
    nieuwsbrief_group_id:
        type: DropDown
        label: Groep
        params:
            dbsource:
                table: nieuwsbrief_groups
                title: naam
                value: id                    
        validators:
            -type: Required
retrieve:
    manage: nieuwsbrief_gebruikers/manage/
    delete: nieuwsbrief_gebruikers/delete/
    pagination:
        base_url: nieuwsbrief_gebruikers/index/
        per_page: 10
    filters:
        -nieuwsbrief_group_id = 3
    fields:
        -email
        -naam

edit: no matter what i do in filters, it doesn't work.
It doesn't even throw an error.

[eluser]Amzad Hossain[/eluser]
First of all, thanks for Rabbit Forms..

I am using BackendPro . I am using your library with that one for my major entity and other stuffs..

When you are planning to publish a full version ??

[eluser]freshface[/eluser]
I added a search function to rabbitforms:

Add this to Libraries:Rabbitform.php

Code:
public function prepare_retrieve_search(array $config, $search_data = "")
    {
         //get code igniter
        $this->ci->load->database();
        $this->ci->load->helper('url');
        
        //var_dump($config['filters']);
        
        //initialize data
        $data = array();
        
        //base data
        $data['manage']  = $config['retrieve']['manage'];
        $data['delete']  = $config['retrieve']['delete'];
        $data['kfields'] = $config['retrieve']['fields'];
        
        //order
        $orderby = $config['retrieve']['orderby'];
        
        if($orderby) {
            $orderby = sprintf('order by %s', $orderby);
        }
        
        $filters = "WHERE ";
        
        
        
        
        //var_dump($config['retrieve']['search']['page']);
        //var_dump($config['retrieve']['search']['fields']);
        
        //filters
        if(isset($config['retrieve']['filters'])) {
            $filters .= '' . implode(' and ', $config['retrieve']['filters']);
        } else {
            //$filters = 'WHERE ';
        }
        
        
        // search
        if(isset($config['retrieve']['search']['page']) && isset($config['retrieve']['search']['fields']))
        {
            $data['search'] = $config['retrieve']['search']['page'];
            $data['seach_fields'] = $config['retrieve']['search']['fields'];
            
            
            if($search_data != "")
            {
            
            
            if(isset($config['retrieve']['filters'])) {
                $filters .= ' AND ';
            }
            
            
            
            for($i = 0 ; $i < count($config['retrieve']['search']['fields']); $i++)
            {
                
                
                if($i>0)
                {
                    $filters .= ' or ';
                }
                
                $filters .= "`".$config['retrieve']['search']['fields'][$i]."`" . ' LIKE "%' . $search_data . '%"';
                
            }
            }
            //$filters .= ' and ' . implode(' or ', $config['retrieve']['search']['fields']) . ' like ' . $search_data;
        }
        
        $pagination = '';

        //create form
        $form = new Rabbit_Form($config['table']);
        $form->setGenerateAssets($config['form']['automatic_assets']);
        $form->setPrimaryKey($config['primary_key']);

        //load field headers
        $fields = $config['retrieve']['fields'];
        $data['fields']  = array();

        foreach($fields as $field) {
            $data['fields'][$field] = $config['fields'][$field]['label'];
        }

        //load fields skeleton
        $skeletons = array();

        foreach($fields as $field) {
            $skeletons[$field] = Rabbit_Field_Factory::factory(
                $config['fields'][$field]['type'],
                $form,
                isset($config['fields'][$field]['params']) ? $config['fields'][$field]['params'] : array());
            $skeletons[$field]->initialize();
        }

        //load rows of data
        $data['rows'] = array();

        $rows = $this->ci->db->query(sprintf(
            'select `%s`, `%s` from `%s` %s %s %s',
            $config['primary_key'],
            implode('`,`', $fields),
            $config['table'],
            $filters,
            $orderby,
            $pagination
        ))->result_array();
        
      
        

        foreach($rows as $row) {
            $form->setEditId($row[$config['primary_key']]);
            $line = array();
            $line['rabbit_row_id'] = $row[$config['primary_key']];

            foreach($skeletons as $field => $skeleton) {
                $skeleton->setRawValue($row[$field]);
                $line[$field] = $skeleton->getDisplayValue();
            }

            $data['rows'][] = $line;
        }
        
        return $data;

    }

Add this to views:rabbit-forms:retrieve_base.php

Code:
&lt;? if(isset($search)):?&gt;
&lt;form action="&lt;?=base_url().'index.php/'.$search?&gt;" method="post" class="search"&gt;
    &lt;input type="text" name="search"&gt;&lt;/input>
&lt;/form&gt;
&lt;? endif; ?&gt;



Now use this in your yml file:

Code:
search:
    page: nieuwsbrief_gebruikers/search/
    fields:
        -email
        -naam

[eluser]Dave Rau[/eluser]
I'm getting ZIP errors when I extract the file from google code. Anyone else having this trouble?

[eluser]daulex[/eluser]
Nope, just downloaded, tested with winrar, it said its fine, opened with 7zip and everything is fine...

Just wanted to say Thank you to Wilker, if you want, I would be happy to help you with the design of the web site for rabbit forms Smile

This thing is amazing.
Thank you.

[eluser]leon_dewey[/eluser]
How would i used Rabbit Forms to create a blog style comment form?

For example where the relationship is not a choice, it is forced.

What I would want is for the post_id to be a hidden field and for that to be populated with the post id that you currently look at. Is this do able?

[eluser]autoreverse[/eluser]
[quote author="Dave Rau" date="1219962878"]I'm getting ZIP errors when I extract the file from google code. Anyone else having this trouble?[/quote]
Yep. Looks like the zip isn't OS X compatible.

1) Open Terminal
2) Change to your working directory e.g.: "cd Sites/ci"
3) Enter "svn export http://rabbit-forms.googlecode.com/svn/trunk/ rabbit-forms"

This will pull the latest version from Google's Subversion repository. P.M. me if you have any trouble

[eluser]Dave Rau[/eluser]
Well OS X still gives me errors, but I did an unzip via terminal and all is well. Thanks for the help daulex and autoreverse.

[eluser]stoefln[/eluser]
is this extension still in development? seams to like wilker is quite inactive the last view months...

[eluser]Amzad Hossain[/eluser]
I have done some very little tweaking with rabbit forms and put an example of that in my blog. Any suggestion will be thankful.

here




Theme © iAndrew 2016 - Forum software by © MyBB