• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Sprintf syntax for Field Element

Status
Not open for further replies.

stevelis

Member
How do I type in the sprintf ucwords coding? - (first letter uppercase, rest lowercase)
Would appreciate an example of the coding for the 'Format String' option in the Formatting tab of an element named "fname" using a Field plugin.

Thanks
Steve
Australia
 
Hi

I don't know how can be done vi the 'Format String' option but I suggest to use a php validation like this:

Code:
return ucwords($data);
The above will return all words of the string with capital first letter

There is also another string function which returns a string with capital first letter only in the first word
Code:
return ucfirst($data);

Just don't forget to put the option to 'Replace'
 
Hi dimoss
Thanks and working as wanted
Easy, when you look it the right place and there is help pointing you there - again thanks

Thanks
Steve
Australia
 
Using the ucfirst coding works if the data is entered in lowercase.
If all the data is entered in uppercase, the whole field stills shows uppercase.
Can and how do you combine both ucfirst and strtolower functions into one code for the PHP Code box for Validation?
I can achieve the desired result by having 2 separate Validations, or is this how you do it.


Thanks
Steve
Australia
 
Hi

If your string is more than one word with capital letters you better use this:

Code:
return ucwords(strtolower($data));

This will convert your words with first letter capital but all the rest with lowercase.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top