#2
Posted 28 February 2012 - 04:43 PM
@somartist | modules created | support me, flattr my work flattr.com
#3
Posted 04 June 2012 - 04:17 AM
Also would be interested in a feature to limit characters for a field (ie: summary fields should only be 256 characters). I know this can be done in the code but I'd really like the user to be told to resubmit his summary if it is too long.
My apologies, don't think I have my head switched on today! Of course you can limit characters on a text field.
Would still be very interested in the required thing though....
Edited by onjegolders, 04 June 2012 - 04:20 AM.
#4
Posted 04 June 2012 - 10:22 AM
Real required field support means letting a copy of a given page exist in some unpublished/draft state, until the requirements are met. Once the requirements are met, it can replace the published page. Until versioning is built in, making this happen is overly complex. So until that happens, any required field support will likely just be symbolic required field support via javascript or PW error messages. People will still want to code their templates to account for empty value situations, even on required fields. That's the primary reason why the 'required' option is hidden in advanced mode, because I don't want to imply that you can always expect some field to always be populated.
Another scenario that not even versioning can fix: lets say you have a site with a bunch of active pages in it. You add a new field to a heavily used template and make it 'required'. All the existing pages will have an empty required field. It's a tricky situation. The expectation of required fields seems to open more potential for site-breaking situations. Better to code things as if required fields didn't exist.
#5
Posted 04 June 2012 - 11:08 AM
Proper required fields aren't quite as easy as they sound in ProcessWire. There are some problematic scenarios. For instance, what if you edit a published page, make a bunch of edits and leave a required field blank. When you save, if there is a missing required field, then logically the save should be aborted. But any other changes you made that were valid would also have to be aborted, otherwise we'd have a page in a partially saved state (which is not possible). A page can't be in two states at once. And if we're saying we support real required fields, we can't have a published page in the system in a state where one of the required fields is blank. So the required field support you see in PW right now is not much more than symbolic, because the page can still exist without a required field populated. PW will complain and give you errors telling you about it, but it can still exist.
Real required field support means letting a copy of a given page exist in some unpublished/draft state, until the requirements are met. Once the requirements are met, it can replace the published page. Until versioning is built in, making this happen is overly complex. So until that happens, any required field support will likely just be symbolic required field support via javascript or PW error messages. People will still want to code their templates to account for empty value situations, even on required fields. That's the primary reason why the 'required' option is hidden in advanced mode, because I don't want to imply that you can always expect some field to always be populated.
Another scenario that not even versioning can fix: lets say you have a site with a bunch of active pages in it. You add a new field to a heavily used template and make it 'required'. All the existing pages will have an empty required field. It's a tricky situation. The expectation of required fields seems to open more potential for site-breaking situations. Better to code things as if required fields didn't exist.
OK thanks for taking the time to explain that!
I think allowing for empty fields will make me a better coder in the long run anyway!
#6
Posted 04 June 2012 - 08:14 PM
I will need to dig deeper into the backend to see what's available.
#7
Posted 06 June 2012 - 11:00 AM
#8
Posted 18 September 2012 - 04:53 AM
This seems to work great so far. Is there anything I'm missing? (since this method isn't mentioned here ...)
#9
Posted 18 September 2012 - 04:04 PM
#11
Posted 19 September 2012 - 12:38 PM
@somartist | modules created | support me, flattr my work flattr.com
#12
Posted 19 September 2012 - 01:20 PM
#13
Posted 19 September 2012 - 02:14 PM
Thanks!
t
#14
Posted 19 September 2012 - 02:22 PM
@somartist | modules created | support me, flattr my work flattr.com
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













