⚠ 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

Hidden



axornet
  • profile picture
  • Member

Posted 04 October 2013 - 15:50 PM

Since I updated to version 1.4.1 the hidden fields are not working. When i try to edit or add, GC is asking for the ID_program field

 

$crud->required_fields('id_program',  'question');

$crud->columns('id_program', 'question');
$crud->add_fields(    'id_program', 'question');
$crud->edit_fields(    'id_program',  'question'); 

 

$crud->field_type('id_program', 'hidden', $id_program);

$crud->set_relation('id_program','program','{name}',array('id_program' => $id_program));

 

Thank you

 

 

 

 

 

 


davidoster
  • profile picture
  • Member

Posted 16 October 2013 - 05:56 AM

Hello and welcome to the forums [member=axornet].

This code you posted doesn't make sense to be honest.

You state the field id_program as required and you also want it to be hidden?

It is either or, you can't have both of these two.


Robert
  • profile picture
  • Member

Posted 16 October 2013 - 06:35 AM

Using relation and using hidden on a field dose not work .. in edit/add you will see the field ... test without the relation and see if it works, this is gc 1.4.0 -1.4.1 problem ..


axornet
  • profile picture
  • Member

Posted 26 October 2013 - 21:36 PM

Thank you for your answers.

 

I have the following relation

 

Programs 1:N activities.

 

My activities tables has :

 

id_activity as a key

id_program as a required field and a FK 

More fields like description, etc, etc

 

My intention is (and is working in version prior 1.4.1) show and allow people CRUD with activities limited to the subset with a particular id_program.

 

I have a CRUD with all my programs, and i have a button to "Work with Activities" in each line. (for example id_program = 100)

When the new page open, only shows me the activities with id_program = 100.

 

There is a better ways to do it?

 

Regards and thank you

Axornet


Jefer
  • profile picture
  • Member

Posted 28 October 2013 - 06:11 AM

I am trying to do the same but It doens't work in GC 1.4.1. I am doing a web page where a user can write consultation to the admin, that's why I need the user_id to be stored in consultation table and the user can't choose another's username (obvious). When I use field_type invisible, the user_id field is still there in add form, with hidden type is the same. Any suggestion?


Robert
  • profile picture
  • Member

Posted 28 October 2013 - 07:42 AM

Atm no .. seams there are some bugs with set relation and callbacks on the same filed ....


edramirez
  • profile picture
  • Member

Posted 09 November 2013 - 19:39 PM

You mentioned "My intention is (and is working in version prior 1.4.1) show and allow people CRUD with activities limited to the subset with a particular id_program."

 

Based on your description, each user has his own subset of activities.

 

Here's how I would do it:

 

(1) Since users are required to log into your system, you should have a session control mechanism whereby the user's identity (user_id perhaps) is visible in all the controllers that he accesses.

 

(2) When the user accesses the controller that you are talking about, your grocerycrud operation must include a where function in order to filter your listing to records with the same user_id. In this way, there is no need to have a set relation function. and the user_id field can be hidden accordingly.

 

The set relation function is a lookup function in a drop-down format. And this will work if and only if the field is visible.

 

Hope this helps.

 

Ed Ramirez


Ravindra Kr
  • profile picture
  • Member

Posted 05 June 2014 - 17:22 PM

I'm trying to assign a 0 to hidden field as default value.

 

But, except 0, every other value is getting accepted. When I enter zero. the value  is blank.

 

$crud->field_type('Approved_Status', 'hidden', 0);

or

$crud->field_type('Approved_Status', 'hidden', '0');

 

The form looks like this:

 

<!-- Start of hidden inputs -->

 

<input id='field-Approved_Status' type='hidden' name='Approved_Status' value='' />

<input id='field-Created_Dttm' type='hidden' name='Created_Dttm' value='2014-06-05 03:20:00' />

 

<!-- End of hidden inputs -->

 

$crud->field_type('Approved_Status', 'hidden', '1'); works absolutely fine.

 

Anybody come across such problem before?


Amit Shah
  • profile picture
  • Member

Posted 05 June 2014 - 20:13 PM

welll i have faced it and understood that 0 is not a value accepted by CI when it parses it to be present.. for it, that is a blank value or false value.

What i recommend in this scenario... set the default value of the mentioned field in the table to be zero.. and remove the constraint for it to be made available..

or .. other thing .. pre-insert .. check if the value set is null or blank.. set it to 0

 

either way .. the solution can be derived..

 

Happy GCing :)