You need to sign in to do that
Don't have an account?
Kevin Strange
Prepend a visualforce inputtext field with a text value if it's not blank -
Hi,
I have a visualforce page with various inputText fields that are being concatenated into a single field - everything is working
However, I would like to "Prepend" or add text to the submitted value but only if it is filled in. Should this be done in the Controller
or can it be achieved in visualforce or both.
Example: I have 2 inputtext fields. One called Fruit the other Vegetables
If someone filled out the Fruit Field with "Apple" but left the Vegetable field blank I would like the result to be:
Fruit: Apple
Vegetable did not pass because it was blank.
Any help would be much appreciated.
Thank You
I have a visualforce page with various inputText fields that are being concatenated into a single field - everything is working
However, I would like to "Prepend" or add text to the submitted value but only if it is filled in. Should this be done in the Controller
or can it be achieved in visualforce or both.
Example: I have 2 inputtext fields. One called Fruit the other Vegetables
If someone filled out the Fruit Field with "Apple" but left the Vegetable field blank I would like the result to be:
Fruit: Apple
Vegetable did not pass because it was blank.
Visualforce <apex:page controller="SubmitCaseController"> <h1>Submit New Case</h1> <apex:form > <apex:pageMessages /> <table> <tr> <th>Your Name:</th> <td><apex:inputText value="{!c.SuppliedName}"/></td> </tr> <tr> <th>Your Email:</th> <td><apex:inputText value="{!c.SuppliedEmail}"/></td> </tr> <tr> <th>Subject:</th> <td><apex:inputText required="true" value="{!c.Subject}"/></td> </tr> <tr> <th>Field1:</th> <td><apex:inputText value="{!Fruit}"/></td> </tr> <tr> <th>Field2:</th> <td><apex:inputText required="true" value="{!Vegetable}"/></td> </tr> <tr> <td><apex:commandButton value="Submit Case" action="{!submitCase}"/></td> </tr> </table> </apex:form> </apex:page> ****************** Apex Controller public class SubmitCaseController { public Case c { get; set; } public SubmitCaseController() { c = new Case(); } //Variables public String Fruit {get; set;} public String Vegetables {get; set;} public PageReference submitCase() { try { // Insert the case c.Description = 'Fruit\n' + 'Vegetable'; INSERT c; return null; } catch (Exception e) { ApexPages.addMessages(e); return null; } } }
Any help would be much appreciated.
Thank You
I was reading up on isBlank(inputString) - My form ultimately will have 20 or so inputtextfields - which will all concatenate into the Case Description field -
Thank you for your help! Could you point me toward an example or two? many thanks....