Jump to content

Question: Field setting


LeiHa
 Share

Recommended Posts

I've been trying to achieve user profile set up just like other CMS doing.

For example, Drupal has various fields available and add lots of feature on it. A field has validation set up like only allowed some other formatting and make it as unique so that no duplicate values are allowed. Some other field are related to each other. and so on.

Now, are these field settings achievable in PW?

1. More complex validation can be done without fixing PHP code? (something like only alphabetical text allowed before the dot and only numbers are allowed after the dot)

2. Make the field set as unique so that no duplication values are not allowed?

3. two or more fields are related to each other and make them as one field?

4. A field can be filled automatically such as 'last logged in time', 'user index number', 'posting numbers', and so on.

Sorry but I got a lot of questions because I'm so excited about new CMS/CMF, ProcessWire concept and design.

Link to comment
Share on other sites


1. More complex validation can be done without fixing PHP code? (something like only alphabetical text allowed before the dot and only numbers are allowed after the dot)
 

There's html5 input field patterns validation coming in 2.3 or it's already there if you use current dev. Field setup under "input" tab "Pattern".

 

2. Make the field set as unique so that no duplication values are not allowed?
 

There's a double no in that sentence. So I guess you didn't mean it. There's no support for this by now. But you can easily hook the page save and add your own validation and checks.

 

3. two or more fields are related to each other and make them as one field?
 

Not sure what that means. But maybe this is what you're looking for. http://modules.processwire.com/modules/fieldtype-concat/

 

4. A field can be filled automatically such as 'last logged in time', 'user index number', 'posting numbers', and so on.
 

Again not sure what you mean by automaticly filled. It's all possible through hooks. It also depends a lot what you're trying to do. If you build frontend users, or just for backend. For frontend you would build the user profile and all it's handling yourself anyway so it's all possible and only your imagination and skills is the limit.

It's like giving someone a toolbox and ask can you build a wooden box?

  • Like 1
Link to comment
Share on other sites

1. More complex validation can be done without fixing PHP code? (something like only alphabetical text allowed before the dot and only numbers are allowed after the dot)

We do provide hooks for adding any kind of additional server-side validation. But like Soma mentioned, the HTML5 pattern option may be adequate for typical admin input. 

2. Make the field set as unique so that no duplication values are not allowed?

While not present as an option on any fieldtypes at present, it is pretty easy to add directly in the DB. And I've left it that way just because the need is so rare, and easy to do when/if needed. You can just add a 'unique' index to the 'data' field in any field_* table. A good example:

ALTER TABLE field_email ADD UNIQUE data_unique (data);
3. two or more fields are related to each other and make them as one field?

I'm not 100% sure what you mean, so I'll cover a few possible answers:

  • You can relate pages using the 'Page' fieldtype
  • You can group two or more fields using the 'fieldset' or 'tab' fieldtypes
  • You can concatenate the values of two or more fields using the 'concat' fieldtype
4. A field can be filled automatically such as 'last logged in time', 'user index number', 'posting numbers', and so on.

This is what hooks are for (again, as already mentioned by Soma). Lots of fun possibilities here. Just let us know if you need help setting one up. 

Link to comment
Share on other sites

While not present as an option on any fieldtypes at present, it is pretty easy to add directly in the DB. And I've left it that way just because the need is so rare, and easy to do when/if needed. You can just add a 'unique' index to the 'data' field in any field_* table. A good example:

ALTER TABLE field_email ADD UNIQUE data_unique (data);
 

Hey Ryan,

Thanks for the tip!

I definitely see the advantage of making sure something is unique.  If inserting pages via the API, would it also be possible to add a conditional using "$pages" to see if something already exists?  Or perhaps a simple function... Or maybe a site-wide config element?

Thanks,

Matthew

Link to comment
Share on other sites

Thanks, Soma and ryan!!!!!

These are big help to me.

Sorry for not enough detailed questions. (I'm a second English speaker.)

And I'm a designer, so there should be a lot of code unfriendly words around. And just started php code. (oh well, took the long way to achieve a goal)

It's great to hear that ver2.3 is coming with html5 input field patterns validation.

About the unique data type, I'll try what you guys say.

Sorry about the related fields.

It could be combing one field, calling related field as needed,  putting into a field as a group, and so on.

But Soma and ryan gave me enough solutions. Thank you so much.

About the automatically filling field type questions, it came out of my mind because of my lack of coding experience.

It will be great experience to figure out all of these, fun possibility just like ryan said.

Thanks again guys.

You guys are fantastic.

  • Like 1
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...