| Index
» Projects
» phpMyEdit
» Forum
» Assigning default value to column..to help everyone. |
 |
kliklinksteve
Joined: 19 Aug 2004
Posts: 1
Posted: 2004-08-19 21:18
Back to top
Reply with quote
|
Hi guys
A question for all, that has not been clearly explained... how do I apply a default value to a hidden column such as column=value?
|
n9yty
Joined: 03 Oct 2004
Posts: 2
Posted: 2004-10-03 02:29
Back to top
Reply with quote
|
I thought this would be easy, but it's proving very difficult... I want a hidden field to be updated automatically based on a PHP variable set in the script before I run the phpMyEdit class...
My 'fdd' looked like this:
$opts['fdd']['location'] = array(
'name' => 'Location Code',
'options' => 'H',
'select' => 'T',
'maxlen' => 3,
'default' => $user_loc
);
The field is always blank in the database for records added. Putting in a `echo` statement in PHP for this web page shows that the variable $user_loc is defined appropriately.
I tried to insert this in to the above, and it didn't help either:
'sqlw' => 'UPPER($user_loc)'
Finally, even doing this didn't help:
$opts['cgi']['overwrite']['location'] = "$user_loc";
I had a similar problem with another field that I used a trigger, which worked, but seemed a lot of extra work for something this simple.
I also think this is related, where I tried to create a dynamic range for a drop-down list to choose the year, starting with the current year as the default:
$temp = getdate();
$opts['fdd']['year'] = array(
'name' => 'Year',
'select' => 'D',
'default' => $temp['year'],
'values' => range(2000, $temp['year']),
'maxlen' => 4,
'required' => true,
'sort' => true,
'js' => array('required' => 'true')
);
However, although the range was right, the default is not set.
Am I missing something obvious? I'm using the latest CVS version of phpMyEdit because I wish to take advantage of some of the new features. Is it possible this is broken in CVS?
Many Thanks! -- Steve
|
michal
Joined: 17 Jun 2003
Posts: 537
Location: Slovakia
Posted: 2004-10-04 10:31
Back to top
Reply with quote
|
the H flag has wierd behaviour. i needed a hidden field (really hidden, so that the user can't see it, not just <.. type=hidden ...>). i had to use triggers. or try options 'HAC' (AC should make it insert to the db, H should make it hidden).
for your second problem, try "range($temp['year'], 2000)" (recalling back, i cannot remember using range option, so just a guess)
|
n9yty
Joined: 03 Oct 2004
Posts: 2
Posted: 2004-10-04 17:48
Back to top
Reply with quote
|
| michal wrote: |
| the H flag has wierd behaviour. i needed a hidden field (really hidden, so that the user can't see it, not just <.. type=hidden ...>). i had to use triggers. or try options 'HAC' (AC should make it insert to the db, H should make it hidden). |
I found this by carefully reading more posts in the forum... Also, I have switched to the new(?) method of separating 'options' from 'input'. So I have a field with 'H' in 'input' and 'A' in 'options', and it seems to be working as I would like.
| Quote: |
| for your second problem, try "range($temp['year'], 2000)" (recalling back, i cannot remember using range option, so just a guess) |
The range portion is working as expected, however the default value is not being used to make the default item in the list be the one selected initiially. This is a small problem, so I am not worried about it right now.
Thanks to the development team for an EXCELLENT solution!
|
|
Post new topic
Reply to topic
|
|
|
|