Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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!

 

 

 

 

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

  • Author

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

there is no 'add name' on that page

  • Author

sorry, click any Paseo Club on the left side

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.

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

  • Author

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!

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.