Jump to content


In set_rules label does not work

set_rules display_as label

  • Please log in to reply
11 replies to this topic

#1 pvalen

pvalen

    Member

  • Members
  • PipPip
  • 15 posts

Posted 31 May 2013 - 11:40 AM

I need to have different  the displaying label for column names in the list in display_as a different in form using set_rules.

But the specified label in set_rules will not be displayed on the form. There will be displayed a column name specified in display_as.

When is entered a name column in set_rules, so it does not appear.

 

$this->grocery_crud->columns('datum', 'nadpis_zk');
$this->grocery_crud
     ->display_as('datum', 'Datum')
     ->display_as('nadpis_zk', 'Nadpis');

 

$this->grocery_crud
     ->set_rules('nadpis_zk','Nadpis zkráceny', 'trim|required|max_length[50]|callback_pomlcky')
     ->set_rules('nadpis_cl','Nadpis celý', 'trim|required|callback_pomlcky');

 

This error is seen in the example to set_rules too.



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 01 June 2013 - 07:10 AM

I am not sure what error you are trying to say.

Check this, 3HMtslk.png

This is from here: http://eletter.gr/sa..._management/add

And the code is this, 

function products_management()
	{
			$crud = new grocery_CRUD();

			$crud->set_table('products');
			$crud->set_subject('Product');
			$crud->unset_columns('productDescription');
			$crud->set_rules('buyPrice','BuyPrice2','numeric');
			$crud->display_as('buyPrice', 'buy Price');
			$crud->callback_column('buyPrice',array($this,'valueToEuro'));
			
			$output = $crud->render();
			
			$this->_gc_output($output);
	}	

At least myself, I can't see any errors or something that doesn't work.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#3 pvalen

pvalen

    Member

  • Members
  • PipPip
  • 15 posts

Posted 06 June 2013 - 08:49 AM

I do not know what version you are using. I'm using version 1.3.3. and it is working wrong.

 

If you look at the example (set_rules) and there you see a mistake

 

grocerycrud_set_rules.jpg



#4 pvalen

pvalen

    Member

  • Members
  • PipPip
  • 15 posts

Posted 06 June 2013 - 10:22 AM

I have a code

...
$this->grocery_crud->set_table('tzp');
$this->grocery_crud->set_subject('zprávu');

$this->grocery_crud->columns('datum', 'nadpis_zk');
$this->grocery_crud
       ->display_as('datum', 'Datum')
       ->display_as('nadpis_zk', 'Nadpis krátký');

// kontrola/validace zadani 
$this->grocery_crud
       ->set_rules('nadpis_zk','Nadpis zkrácený', 'trim|required|max_length[50]|callback_pomlcky')
       ->set_rules('nadpis_cl','Nadpis celý', 'trim|required|callback_pomlcky')
       ->set_rules('autor','Autor', 'trim|required|max_length[50]|callback_pomlcky')
       ...

 

 

I have another column name in the list

grocerycrud_set_rules_01.jpg
 

 

and the form

grocerycrud_set_rules_02.jpg
 



#5 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 06 June 2013 - 01:17 PM

You need to use the function display_as. It's different from set_rules!

$crud->set_rules('buyPrice','BuyPrice2','numeric');
$crud->display_as('buyPrice', 'buy Price');

 

Check the manual for the differences.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#6 pvalen

pvalen

    Member

  • Members
  • PipPip
  • 15 posts

Posted 06 June 2013 - 01:38 PM

Thank you, I know it.

But I need to have with same column different name in the list and different in the form.

What does the second parameter in the set_rules?  In the manual is not written on what it is used. In description for the function set_rules says "string $label". That's why I thought the typed text appears as a label.



#7 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 06 June 2013 - 03:13 PM

Use then the callback_column and the callback_field to change the output of the field!


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#8 pvalen

pvalen

    Member

  • Members
  • PipPip
  • 15 posts

Posted 07 June 2013 - 08:10 AM

Sorry for my English.
But we do not understand.
I do not want to change the contents of the column, but I want to change only its name. That's how it will appear. I want to have a different column name in the list and different column name in the form.
For example:
The column is called "price"
In the list I want you but previewed his name as "PRICE XXX". A form I want to display his name as "Price YYY".

 

And again I ask. What does the second parameter in the set_rules?
In the manual is not written on what it is used.

 



#9 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 09 June 2013 - 05:22 AM

For the list, $crud->display_as('price', 'PRICE XXX');

For the form (inside the controller's function), $crud->callback_field('price', array($this, '_cb_price'));

and then add this callback function,

 

function field_callback_1($value = '', $primary_key = null)
{
return 'PRICE YYY <input type="text" maxlength="50" value="'.$value.'" name="price" style="width:462px">';
}

 

For the set_rules read at the documentation.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#10 pvalen

pvalen

    Member

  • Members
  • PipPip
  • 15 posts

Posted 10 June 2013 - 07:14 AM

I'm sorry, I am badly understood documentation. I thought that the specified parameter is "label" and not just
and "human" name for this field, which will be inserted into the error message.

 

But the solution using callback_, as I wrote in my post
http://www.grocerycr...-and-elsewhere/
is complicated and useless to insert the file, date, etc.



#11 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 10 June 2013 - 12:16 PM

But the solution using callback_, as I wrote in my post

http://www.grocerycr...-and-elsewhere/
is complicated and useless to insert the file, date, etc.

 

What the date issue you posted elsewhere has to do with this issue here?

Please don't mix and match questions(issues) because other people that search on the forums might get confused!

Thank you.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#12 JpunkLy

JpunkLy

    Member

  • Members
  • PipPip
  • 15 posts

Posted 24 June 2013 - 10:21 AM

hmmmm....I'm So Confused.... :(


Visit My Page -> http://nugashare.me.pn |  @DianNugraha702






Also tagged with one or more of these keywords: set_rules, display_as, label

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users