read only field not inserted or displaying

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
User avatar
wsiconcrete
Posts: 18
Joined: 2015-04-27 16:39
Location: SC, USA

read only field not inserted or displaying

Post by wsiconcrete » 2015-04-27 16:48

New to AppGini and so far it has been a breeze for a (very) novice web dev.

Got my app up and running but I am having trouble with a field that I want to be read only not showing up. The field has data type 'decimal' and property of 'unsigned'. I am calculating the field value using the _before_insert function in the hook file. In the last line of that function I set the value as follows:

Code: Select all

$data['field id'] = number_format(my calculation);
If I uncheck the read only property the field calculates and is inserted into the dB. When I check the read only field, the calculated value is NOT inserted into the dB and does not show up on the detail view or table view.

Am I doing something wrong or is there some other way I should handle a read only field? Sorry if I have missed this somewhere but didn't find any references in the online help or forums.

Thanks!
Brandon

User avatar
a.gneady
Site Admin
Posts: 1287
Joined: 2012-09-27 14:46
Contact:

Re: read only field not inserted or displaying

Post by a.gneady » 2015-04-28 23:37

For read-only fields, you can't set their value using the $data array in the before_insert hook ... Instead, use an explicit update query in the after_insert hook, or uncheck the read-only option for the field, and set it to read-only using javascript code in hooks/tablename-dv.js (create that file if it doesn't exist -- where tablename is the name of the concerned table) ... To set a field as read-only in javascript, you could use code like this in that file:

Code: Select all

$j(function(){
    $j('#field_name').prop('readonly', true);
});
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

User avatar
wsiconcrete
Posts: 18
Joined: 2015-04-27 16:39
Location: SC, USA

Re: read only field not inserted or displaying

Post by wsiconcrete » 2015-04-29 04:42

Thank you!!!

You make this too easy for someone like me who knows just enough to get myself in a jam doing this. I understand a bit of programming, I just don't think like a programmer I guess. I already had the custom js files in the hooks folder enforcing character limits on some of the other inputs but it just didn't occur to me to go this route for readonly...

Anyway, I used the jQuery function like the one I found referenced for the character limits somewhere else on this board.

Code: Select all

jQuery('#mst_moisture').prop('readonly', true);
Thanks again for the help and for creating this product! I spent the better part of a month trialing various options (other php generators, online web app sites, etc) before coming back to AppGini. Wish now I would have downloaded this a month ago as it literally took me less than an hour to have a functioning app online.

Diogenes
Posts: 16
Joined: 2015-05-07 14:03

Re: read only field not inserted or displaying

Post by Diogenes » 2015-05-07 14:46

I am reading some great coding tips in the forums. Many of the tips are solutions for instances that come up frequently.

Can't App-Gini have some kind of updatable module installed like a plugin that contains all of these variances and different jQuery methods available to apply in the appropriate custom hook area?

Even use them in wizards such as the Dreamweaver behaviors wizard.

Javascript in particular is pretty easy to Wizardize and choose objects available in a page of code and apply actions based on this preference and that.

And am I correct in seeing that there is no Community available here that uses AppGini as the foundation of applying customization plugins or modules?

If you could do that, as Wordpress does, "There's a Plugin for that..." your sales would leap as people saw that as the final reason to pick AppGini.

I just spent months researching, researching. Had I seen that Users were creating solutions, too, and making them available in Plugins which were advertised and marketed I would have bought AppGini the first time I saw it.

Post Reply