Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

php edit form, get dropdown to pull value for that record


This topic is 3326 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi, I was successful in creating records with drop down valuelists from my db, now I'd like an edit form on a new page to show those values and edit them. I only see the unedited drop down lists in the edit form.  Here is some code:


$layout =& $fm->getLayout('mylayout');
$values = $layout->getValueList('statelist');
$statelist = '<select name="State">';
foreach ($values as $value) 
    {
       $statelist .='<option value="' . $value . '">' . $value . '</option>';
    }
$statelist .= '</select>';

 

 $edit = $fm->newEditCommand('mylayout', $_POST['id']);
 $edit->setField('State', $_POST['State']);
 $edit->execute();


$record = $fm->getRecordById('mylayout', $_GET['id']);
$State = $record->getField('State');


<td><?php echo $statelist; ?></td>

 

Thanks so much!

 

 

 

 

Posted

Can you give an example? Your code snippet  doesn't really convey what you are trying to do

Posted

hi Doughemi, go to this link and click 'add name'.  in the new pop up, add a name with some drop down values.  dump that page and refresh the original page and click your persons first name.  in the edit pop up, your value list items are reset to original settings, not showing the changes you made.

http://ssvtennis.com/results.php?clubnumber=7061&Club=Paseo Club&clubtype=club

here is my edit file, thanks!

editnew.php

Posted

I can't see anything wrong with editnew.php on paper. 

At the beginning of your php code, put 

ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_DEPRECATED);

You will need to put in some echo statements for troubleshooting to see if variables really got set correctly; e.g.

echo '$variable = ' $variable;

Also, you will need to put in some error checking after all your execute() statements to see why FM doesn't execute the setField() statements.

$someVariable->execute();
if(FileMaker::isError($someVariable){
    echo '<p>Error $someVariable: '. $someVariable->getCode() . ' ' . $someVariable->getMessage() . '</p>';
}

Of course, these can be removed or commented out once you go live.

Posted

I get an error: Warning: implode(): Invalid arguments passed in /home/randyinla/public_html/editnew.php on line 76

$statelist = implode("\r", $_GET['statelist']);

Is this line necessary? Two this on the surface I that look suspect:

1) The error line uses a GET var which should be in the URL somewhere. The Implode() function require the second parameter to be an array.

2) This is in the section where all data is being extracted from a POST array.

It seems like your form is out of scope to allow the to be re-generated after EDIT. I modified it, normalized indenting (for readability), and added some comments. Please take a look.

Hope this helps!

editnew_dwdc.php

Posted

Thanks DWdata, that worked great.  I appreciate your time and effort writing code for this solution.  Can I buy you a beer?!

 

Thanks Doughemi for your help and pointing me in the right direction!

  • Like 1

This topic is 3326 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.