⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

In set_rules label does not work



pvalen

pvalen
  • profile picture
  • Member

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.


davidoster

davidoster
  • profile picture
  • Member

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/samples/gc_ic/index.php/gc_examples/products_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.


pvalen

pvalen
  • profile picture
  • Member

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


pvalen

pvalen
  • profile picture
  • Member

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
 


davidoster

davidoster
  • profile picture
  • Member

Posted 06 June 2013 - 13: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.


pvalen

pvalen
  • profile picture
  • Member

Posted 06 June 2013 - 13: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.


davidoster

davidoster
  • profile picture
  • Member

Posted 06 June 2013 - 15:13 PM

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


pvalen

pvalen
  • profile picture
  • Member

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.

 


davidoster

davidoster
  • profile picture
  • Member

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.


pvalen

pvalen
  • profile picture
  • Member

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
/topic/1735-the-date-format-used-in-europe-and-elsewhere/
is complicated and useless to insert the file, date, etc.


davidoster

davidoster
  • profile picture
  • Member

Posted 10 June 2013 - 12:16 PM

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

/topic/1735-the-date-format-used-in-europe-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.


JpunkLy

JpunkLy
  • profile picture
  • Member

Posted 24 June 2013 - 10:21 AM

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