0

I am newbie at visualforce and i have a few questions. I was able to create a basic visualforce page:

<apex:page standardController="Campaign">
<apex:sectionHeader title="Campaign" subtitle="Campaign Edit"/>
           <apex:form id="theForm">
           <apex:pageBlock title="Campaign" mode="edit">
           <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
                <apex:commandButton value="Save & New" action="{!'save & new'}"/>
            </apex:pageBlockButtons>
           <apex:pageBlockSection title="My Content Section" columns="2">
            <apex:inputText value="{!Campaign.name}" id="name"/>  
                 <apex:inputfield value="{!Campaign.Campaign_Type__c}">
                    <apex:actionSupport event="onchange" reRender="theForm" />
                 </apex:inputField>
                 <apex:inputtext value="{!Campaign.PPC__c}" rendered="{!Campaign.Campaign_Type__c == 'Campaign Type 1'}" />
                 </apex:pageBlockSection>
       </apex:pageBlock>
    </apex:form>

https://ibb.co/iWSVVS

The field "Campaign name" is a required field how can i add the red bar next to the field?

How can I "combine" several fields together and insert them as a value to the field Campaign name? for example i have a dropdown field "Campaign_Type__c=Type 1" and i also have a text box field "Campaign_textbox1__c=alex" I want to combine them as "Type 1 alex" and set this as a value for the field name "Campaign name".

Thank you

user3617337
  • 23
  • 1
  • 8

3 Answers3

3

For the required just set the attribute to the tag:

<apex:inputText value="{!yourVaue}" id="yourid" required="true" />
utm
  • 290
  • 3
  • 6
0

Can you not do a formula field for the Campaign name?

One that concatenates the fields together. So create a formula field called Campaign name, then use my formula below:

Campaign Name = Campaign_Type__c & " " & Campaign_textbox1__c

The reason for the space is that otherwise it'll stick it together like "Type 1Alex"


With your other question, i'd just use HTML formatting to get this. Maybe use a pipe? | - one that's bold and red - but i'm lazy

0

Add the attribute required="true" to make it required i.e. red bar next to the field.

Therefore, you can achieve this by

<apex:inputText value="{!Campaign.name}" id="name" required="true"/>
Noor A Shuvo
  • 2,639
  • 3
  • 23
  • 48