i want to clear/empty an input box on click of a button.i am using:
propInp.setValue("");
where propInp is the binding name of inputbox.
my input box is as:
<af:inputText label="UPC :" id="it2"
binding="#{w9manageBean.propInp}"
autoSubmit="true"
showRequired="true"
disabled="true" partialTriggers="::s1:cb1"
required="true"/>
But this is not working...any solution?
You need to define the value attribute for that inputText and set that backing bean property to an empty string.
<af:inputText label="UPC :" id="it2"
binding="#{w9manageBean.propInp}"
autoSubmit="true"
showRequired="true"
disabled="true" partialTriggers="::s1:cb1"
required="true"
value="#{w9manageBean.myInput}"/>
Add variable myInput to the managed bean and setter and getter for it. Then you can programaticaly set any value you want for that variable and it will be displayed in UI.
I can google and get a few different answers.
Maybe this post will help?
http://biemond.blogspot.com/2009/02/reset-clear-adf-page.html
Related
Hello i have some question
follow this simple example: https://codesandbox.io/s/ww40y2m595
how to make Field Sauces (checkbox) is only one select like Field Best Stooge(radio) ?
****** Field Sauces still use input type = checkbox ************
ex.i try some way such as use mutators function to changvalue but still not work
You can change all the checkboxes with name sauces from type checkbox to type radio if you only want one to be selected.
Example (CodeSandbox)
<label>
<Field name="sauces" component="input" type="radio" value="guacamole" />
Guacamole 🥑
</label>
I have created dynamic form, here I want to send form data to controller. How can do this?
Here is plunker code link https://plnkr.co/edit/xmxDJHTPfJoSFwa2FWCB?p=preview
Issues:
when I change the value then element label also change.
How can I get the form data in product_submit function of controller.
All response appreciated.
Use
<input type="text"
id="module_module"
ng-model="getCol.value"
required="required"
class="form-control col-md-7 col-xs-12"
placeholder="Enter {{getCol.Field}}"
/>
Look here ng-model="getCol.value". You are using filed name as text field model value. Filed name and value are different. That is what you want I suppose.
You can access the values easily from your controller as $scope.getColumn[1].value. Change index or iterate accordingly.
Plunker here
To solve label issues, in your html, I changed ng-model expression to bound into getColumn.Value
In controller, I can read value entered in scope.getColumn[i].Value
I also updated code https://plnkr.co/edit/KlhAb69seMzHsLuhqweR?p=preview
I'm using angular-auto-validate and am having some state management issues. I have a multipart form where some fields are required (name/email address) and the user is able to go "back" to change answers. Basically, I have a partial for every stage in the form which is working well, with one exception. The continue button is disabled if the field is invalid. I tried simply using the $valid identifier, but when the partial loads, each field begins with ng-valid so I can either use $touched or $pristine. Problem is, when the user goes back, the value that has binded to a data source is valid, but the field isn't touched so the continue button doesn't activate. Sample code (this is generated code after I've hit the "back" button):
<input type="text" name="name" ng-minlength="3" ng-model="myModel" placeholder="Your First Name" ng-focus="inputFocused()" ng-pattern-err-type="" ng-model-options="{updateOn: 'blur'}" class="ng-valid ng-valid-pattern ng-valid-minlength">
and the button:
Continue
How can I either disable the default ng-valid or identify a condition where the value is being populated by the controller?
I think you should use ng-dirty/pristine. You can manually set the condition of the form as the user navigates.
When you populate your form data you can do something like:
if($scope.myForm.data) {
$scope.myForm.$setDirty
}
Your button:
Continue
I'm using an inputField that is binded directly to a custom objects field in the controller.
The following will generate a dropdown list with a label.
<apex:inputField value="{!Agency_Profile.Location_Principal_Activity__c}" />
My problem is that I need to add the required mark next to the inputField without losing the label or having default error msgs.
when I used
<apex:inputField value="{!Agency_Profile.Location_Principal_Activity__c}" required="true"/>
I got the required mark but I lost my custom error msgs for validation.
when I used
<apex:outputPanel styleClass="requiredInput" layout="block">
<apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:inputField value="{!Agency_Profile.Location_Principal_Activity__c}" />
</apex:outputPanel>
the labels near the dropdown list didnt show anymore..
Is there a way I can accomplish what I need?
I ended up using this.
//this part to add the missing label.
<apex:outputLabel styleclass="labelCol" value="{!$ObjectType.Agency_Profile__c.fields.Location_Principal_Activity__c.Label}" />
<apex:outputPanel styleClass="requiredInput" layout="block">
<apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:inputField value="{!Agency_Profile.Location_Principal_Activity__c}" />
</apex:outputPanel>
The best way is to add validation rule for this field for this object.
using raym0nds approach, this is how it looks for a custom controller variable, in my case with the name from a custom field of an object.:
//this part to add the missing label.
<apex:outputLabel for="myId" styleclass="labelCol" value="{!$ObjectType.Agency_Profile__c.fields.Location_Principal_Activity__c.Label}" />
<apex:outputPanel styleClass="requiredInput" layout="block">
<apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:inputText id="myId" required="true" value="{!myCustomField}" label="{!$ObjectType.Agency_Profile__c.fields.Location_Principal_Activity__c.Label}" />
</apex:outputPanel>
note the apex:inputText type which now has an label, id and required attribute. The apex:outputLabel now has a for attribute. The for/id is just so clicking on the label will put the cursor into the right field. The required enables form validation, because the rest is just make-up. The label adds a good field name to that validation error - otherwise it would show the internal field id there.
the whole approach is interesting if you have a mass edit table in which all records share certain values (e.g. add multiple leads for the same company)
I have a requirement in which a Text field has to be made editable or rendered when a check box is checked, how can I achieve this?
Here's a strictly Visualforce code sample that will work as well:
<apex:pageBlock id="theBlock">
<apex:inputCheckbox value="{!theSObject.CheckBox__c}">
<apex:actionSupport event="onchange" rerender="theBlock"/>
</apex:inputCheckbox>
<apex:inputText value="{!theSObject.TextField__c}" disabled="false" rendered="{!(theSObject.CheckBox__c == true)}"/>
<apex:inputText value="{!theSObject.TextField__c}" disabled="true" rendered="{!(theSObject.CheckBox__c != true)}"/>
<!-- Or to simply have a field that appears only when the box is checked -->
<apex:inputText value="{!theSObject.TextField__c}" rendered="{!(theSObject.CheckBox__c == true)}"/>
</apex:pageBlock>
In addition to this, you can add an action in the action support if you wish to do further processing in Apex, like this:
<apex:actionSupport event="onchange" action="{!myMethod}" rerender="theBlock"/>
Hope that helps
You can use javascript to toggle the disabled attribute of the text input element. Below is a sample page showing how, note, there are a few oddities in here.
First, if you disable the field initially using disabled="true" on the <apex:inputText> then even if you enable it, values entered will not be sent back to the controller, hence disabling the field on load with javascript. I believe this is to prevent any chance of updating a field's value when the developer has specified that it should be disabled.
The second odd point is that even though you set element.disabled to "disabeld" to disable an element, to check whether it is disabled you have to treat it as a boolean value!
<apex:page standardController="Contact">
<apex:form >
<script type="text/javascript">
function ToggleInput(theId)
{
var e = document.getElementById(theId);
if(e != null)
{
e.disabled = (e.disabled ? false : "disabled");
}
}
window.onload = function () { document.getElementById('{!$Component.textInput}').disabled = "disabled"; }
</script>
<apex:inputCheckbox onchange="ToggleInput('{!$Component.textInput}');" value="{!Contact.Some_Checkbox__c}"/>
<apex:inputText id="textInput" value="{!Contact.Some_Text_Field__c}"/>
<apex:commandButton action="{!Save}" value="Update"/>
</apex:form>
</apex:page>
To do all this without javascript, I imagine you'd set the <apex:inputText>'s disabled attribute based on the value of the checkbox field, then use an <apex:actionSupport> tag to fire an action when the checkbox changes and specify the id of the <apex:inputText> in the rerender attribute. You'd also have to wrap it in an <apex:actionRegion> to prevent other fields being sent and causing validation errors if required fields aren't filled etc.. This also means you have to wait for a request to change the state of the text field, so the javascript is the best route for speed.