Web2py: how to set contents of a textarea after it is defined - forms

I'm using web2py to create an SQLFORM which updates some (currently empty) text fields:
form = SQLFORM(db.table, db.table(1), fields = ['blank_name'])
Which creates a textarea tag with name='blank_name'. I then want to set the default text for this text area to some variable. So I've tried
form.element(_name='blank_name').update(_value='My default value')
but this just sets the 'value' attribute of the textarea to 'My default value'. How can I set the contents of the previously blank textarea to a value?

The simplest approach is simple to set the field default (before creating the form):
db.table.blank_name.default = 'My default value'
Regarding the original approach, the web2py HTML helpers act like lists with regard to their components (i.e., contents), so you could use the .append or .insert methods to update the contents.

Related

TYPO3: Set type specific default values in TCA

In my environment it is possible to set the default value for all content elements using
$GLOBALS['TCA']['tt_content']['columns']['rowDescription']['config']['default'] = 'Default Value';
But overriding for one specific content element is not possible:
$GLOBALS['TCA']['tt_content']['types']['new_ce']['columnsOverrides']['rowDescription']['config']['default'] = 'New Description';
All other configurations can be changed (like the label):
$GLOBALS['TCA']['tt_content']['types']['new_ce']['columnsOverrides']['rowDescription']['label']= 'This is the new label';
How can I modify the default value for new_ce?
Afaik not possible currently.
Technical reason in formEngine is that the TCA value defaults are applied before the 'type' is calculated since the default values influence type determination. Thus, they can't be swapped.
Also, this is not possible via page TSconfig since TCAdefaults also handles no type specific settings.

Access Copy Value of Textbox on text change

I've a form in MS access that holds a subform showing records from a table. I've got a textbox whichs content is based on the selected record form the subset. If i select a record with id 2 then the value of the textbox is set to 2.
I want to copy the value of the textbox to another textbox of the form each time the value is changed.
The onChange eventhandler on the textbox bound to the subform does not trigger, neither does any other event when i select a record in the subform.
I'd either write some vba code to copy the text or use a makro.
It probably is triggering if you change the field manually, e.g., this code works for me:
Private Sub Text0_Change()
Text2.Value = Text0.Text
End Sub
(note value and text, as what you see in the field while you are editing it is not that same as the value of the field)
but not if you update it through VBA
Setting the value of a control by using a macro or Visual Basic doesn't trigger this event for the control. You must type the data directly into the control, or set the control's Text property.
https://msdn.microsoft.com/en-us/library/office/ff821734.aspx
If the fields were named like in my example, I'd have whatever VB that updates Text0 also update Text2

Define default value for plain input field (Templavoila)

I tried to set the field "Sample Data" on the "Configuration" page when mapping a data element with Templavoila. But it seems it is used for something else.
Is it possible to define default values for fields like "Plain input field"?
Open the Templavoila DS/TO editor, select your field and add following to "Form"
<default>Your default value</default>
Heres an example:

Word forms - display a form value in text below the form

how to display a value from MS Word Form.
Eg:
I have a form with one dropdown list with following values:
DropDown1: a, b, c
When I select value a, I want to display the value in plain text. Eg:
Value of the selected field is: a.
I would prefere not to use vba.
You can use the (assuming DropDown1 is a ComboBox control) ComboBox's Change routine.
Private Sub DropDown1_Change()
Selection.TypeText DropDown1.Value
End Sub
If it is a "legacy form" (not a form with ActiveX controls or content controls, then
a. set the properties of the dropdown to calculate on exit, and the "bookmark" to (say) dropdown1.
b. put a { REF dropdown1 } field in the document where you want the value
c. protect the form in the usual way.
The value will only appear when the user tabs out of the dropdown.
It's not exactly "plain text", but it's not a form field either. If you need "genuine plain text", you would need code.
If it is a content control, then you would need to set up a Custom XML part and link the dropdown to it, then insert a plain text content control that was also linked to the same element/attribute in that part. That requires code at design time (or a third party add-in, or Word 2013) but not at run time.

How to add a custom field button to a field in SugarCRM

I looked through the developer blogs and I can only find ways to create a custom global form button or to replace a field with custom code. I don't want to replace the field, I want to add a button beside a field.
Here's what I have in mind:
[Date Field][date_picker_button] [time field][time_is_now]
The button I want to add is the time_is_now, allowing the user to populate the time field with the current time.
I have tried updating custom/modules/Notes/metadata/quickcreatedefs.php with:
array (
'name' => 'billable_start_c',
'label' => 'LBL_BILLABLE_START',
'customCode' => '<button</button>',
)
But this replaces the input field with the custom code. I could just put in the stock code and then my custom code, but date fields use yui and a widget, so I'd prefer not to.
Is there anyway to do something like:
'customCode' => '{default} <button></button>',
so that the default code gets output and then the custom code?
You could create a new SugarField template, which will essentially allow you to create the markup for your field. If you named your SugarField TimeIsNow, you could create a field with that type (instead of text,int, date or whatever). You should take a look at some of the other SugarFields to see how they are formatted, but it's really just HTML. When the field is set to that type, it pulls in that HTML template. You can tie your JS to the onclick function. Sugar is very easy to customize, so I definitely wouldn't get in the habit of solving all your customization needs this way...It's another way to look at it though.
Don't use custom code if you can help it. Either copy over the tpl to custom/modules/[yourmodule]/tpls/[yourtemplate] and code the bitton in there or use an after_ui_frame hook and some js to insert you custom button into the DOM.