jbarnes
Joined: 19 Feb 2005
Posts: 6
Posted: 2005-02-19 19:24
Back to top
Reply with quote
|
I think the program is great...
I am new to php and mySQL..
phpMyEdit is installed and works fine.
What I would like to do is is in the edit mode clear a field of it value.
So that the user would have to put in a new value before submitting the form.
in example:
modified_by from the database reads jbarnes
in edit mode I would like it cleared so a user would have to enter their id
as this field is a required value.
Any help would be appreciated.
|
michal
Joined: 17 Jun 2003
Posts: 537
Location: Slovakia
Posted: 2005-02-19 20:35
Back to top
Reply with quote
|
i believe this is not doable by pme configuration.
it could be done by pre update trigger by nulling that value in db, however that would lead to a mess.
another possibility is to hack core class. hack would be like 2 lines, but you need little php knowledge for that...
|
jbarnes
Joined: 19 Feb 2005
Posts: 6
Posted: 2005-02-19 20:54
Back to top
Reply with quote
|
| michal wrote: |
i believe this is not doable by pme configuration.
it could be done by pre update trigger by nulling that value in db, however that would lead to a mess.
another possibility is to hack core class. hack would be like 2 lines, but you need little php knowledge for that... |
michal,
I need this function, could you provide an exple of yourr 2 line hack to the core class.
|
michal
Joined: 17 Jun 2003
Posts: 537
Location: Slovakia
Posted: 2005-02-19 21:02
Back to top
Reply with quote
|
add this line
if($this->fdd[$k]['make_blank']==true) $row[$k]=NULL;
somewhere to beggining of display_change_field($row, $k) function
(if i understood right your needs)
|
jbarnes
Joined: 19 Feb 2005
Posts: 6
Posted: 2005-02-19 21:18
Back to top
Reply with quote
|
| michal wrote: |
add this line
if($this->fdd[$k]['make_blank']==true) $row[$k]=NULL;
somewhere to beggining of display_change_field($row, $k) function
(if i understood right your needs) |
if I Understand you right, the below line is a hack to core:
if($this->fdd[$k]['make_blank']==true) $row[$k]=NULL;
and this line "display_change_field($row, $k) function"
would be a hack to the base document.
$opts['fdd']['modified_by'] = array(
'name' => 'Modified By',
'select' => 'T',
'options' => 'AVCPDF',
'maxlen' => 14,
'function' =>'display_change_field($row, $k)'
'required' => true,
'sort' => true
);
If I'm correct, where would I insert the change in the core?
|
michal
Joined: 17 Jun 2003
Posts: 537
Location: Slovakia
Posted: 2005-02-19 21:25
Back to top
Reply with quote
|
no, search phpMyEdit.class.php for that function and add that line into that function.
(plus make option 'make_blank'=>true in configuration file, which will make certain column blank in edit)
|
jbarnes
Joined: 19 Feb 2005
Posts: 6
Posted: 2005-02-19 21:45
Back to top
Reply with quote
|
| michal wrote: |
no, search phpMyEdit.class.php for that function and add that line into that function.
(plus make option 'make_blank'=>true in configuration file, which will make certain column blank in edit) |
Ok, think I have it?
function display_change_field($row, $k) /* {{{ */
// jbarnes core hack
if ($this->fdd[$k]['make_blank']==true) $row[$k]=NULL;
// jbarnes core hack
{
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('input', null, true, $css_postfix);
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
echo $this->getColAttributes($k),">\n";
if ($this->col_has_values($k)) {
$vals = $this->set_values($k);
$multiple = $this->col_has_multiple_select($k);
$readonly = $this->readonly($k);
$strip_tags = true;
$escape = true;
echo $this->htmlSelect($this->cgi['prefix']['data'].$this->fds[$k], $css_class_name,
$vals, $row["qf$k"], $multiple, $readonly, $strip_tags, $escape);
} elseif (isset($this->fdd[$k]['textarea'])) {
echo '<textarea class="',$css_class_name,'" name="',$this->cgi['prefix']['data'].$this->fds[$k],'"';
echo ($this->readonly($k) ? ' disabled' : '');
if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
}
if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
}
if (isset($this->fdd[$k]['textarea']['wrap'])) {
echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
} else {
echo ' wrap="virtual"';
}
echo '>',htmlspecialchars($row["qf$k"]),'</textarea>',"\n";
} else {
$size_ml_props = '';
$maxlen = intval($this->fdd[$k]['maxlen']);
$size = isset($this->fdd[$k]['size']) ? $this->fdd[$k]['size'] : min($maxlen, 60);
$size && $size_ml_props .= ' size="'.$size.'"';
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
echo '<input class="',$css_class_name,'" type="text" ';
echo ($this->readonly($k) ? 'disabled ' : '');
echo 'name="',$this->cgi['prefix']['data'].$this->fds[$k],'" value="';
echo htmlspecialchars($row["qf$k"]),'" ',$size_ml_props,'>',"\n";
}
echo '</td>',"\n";
} /* }}} */
function display_password_field($row, $k) /* {{{ */
and
$opts['fdd']['modified_by'] = array(
'name' => 'Modified By',
'select' => 'T',
'options' => 'AVCPDF', // updated automatically (MySQL feature)
'maxlen' => 14,
'make_blank'=>true,
'required' => true,
'sort' => true
);
is this right?
|
michal
Joined: 17 Jun 2003
Posts: 537
Location: Slovakia
Posted: 2005-02-19 21:50
Back to top
Reply with quote
|
maybe, did you try it ?
but probably the new line has to go after '{' (since { and } make the function...)
|
jbarnes
Joined: 19 Feb 2005
Posts: 6
Posted: 2005-02-19 21:54
Back to top
Reply with quote
|
as you suggested I put it after {
didn't work field is still populated with orignal data.
|
michal
Joined: 17 Jun 2003
Posts: 537
Location: Slovakia
Posted: 2005-02-19 22:24
Back to top
Reply with quote
|
sorry, it should be $row['qf'.$k]=NULL; and not $row[$k]=NULL;
|
jbarnes
Joined: 19 Feb 2005
Posts: 6
Posted: 2005-02-19 22:31
Back to top
Reply with quote
|
Works like a champ!!!!
Thank you, Thank You.
If you get to the states, beers on me.
|
|
Post new topic
Reply to topic
|
|