Jump to content

How to access a Form Builder field entry?


Daniele
 Share

Recommended Posts

15 hours ago, bramwolf said:

I'm trying to sort the foreach results from FormBuilder but I can't seem to sort it by a field, only by created.
How would you go about doing so?

You can get the array of entries and then do a usort():

$entries = $forms->get('reserveren')->entries()->find('');
// sort entries newest to oldest by field 'datum'
usort($entries, function($a, $b) {
    return $b['datum'] - $a['datum'];
});
// OR, sort entries oldest to newest by field 'datum'
usort($entries, function($a, $b) {
    return $a['datum'] - $b['datum'];
});
// do what you want with $entries array

 

  • Like 1
Link to comment
Share on other sites

Thanks Robin!

That did the trick perfectly! I'm adding this to my FormBuilder Readme file, and I think stuff like this should be included in it
by standard. Most people say this isn't even possible, now it turns out it is, it would be nice if a hunt for this kind of syntax
wouldn't take 2 hours.

Thanx again :)

Bram 

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...