⚠ 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

How to not allow some fields in add an item page



Joeb
  • profile picture
  • Member

Posted 16 December 2015 - 04:54 AM

I have a sensor page that uses the default values when I created the table except for 4 columns.

In the library for grocery grud I used an if stament to get my default fileds to show up on the add page.

 

I would like to be able to show the default fields in the add page but not let them enter anything into them.

 

I used $crud->field_type('gaugetype', 'readonly'); but I then get nothing at all in the field but still want to se the default values.

 

I would like to use my same if statement but do not know where to put it.

 

Anyone have an idea?
 

 


Joeb
  • profile picture
  • Member

Posted 16 December 2015 - 05:07 AM

Here is the code I used to get my default values. Look at the 3 lines commented with //New

protected function get_string_input($field_info,$value)
    {
        $value = !is_string($value) ? '' : str_replace('"',""",$value);
            if (empty($value)) {  //new
                $value = $field_info->default;  //new
                       } //new
            $extra_attributes = '';
        if (!empty($field_info->db_max_length)) {

            if (in_array($field_info->type, array("decimal", "float"))) {
                $decimal_lentgh = explode(",", $field_info->db_max_length);
                $decimal_lentgh = ((int)$decimal_lentgh[0]) + 1;

                $extra_attributes .= "maxlength='" . $decimal_lentgh . "'";
            } else {
                $extra_attributes .= "maxlength='{$field_info->db_max_length}'";
            }

        }

 

 


Amit Shah
  • profile picture
  • Member

Posted 16 December 2015 - 09:36 AM

Well frankly speaking, your question titled and your question narrated are both different in context.. !! What i understood from your query in the question as context is clearly, you looking for setting default values in the add form of yours .. thats where you need to search relevantly in the forum.. there are ppl who have shared solution for the same.

 

Happy GCing :)