310 Posts
ricco
4 years ago
9
Topic

Hi,

Is there a way to get the value of a field in the default value of another field, eg text area?

I've tried

<?php echo $cck->getValue('myField'); ?>

$cck->getValue('myField');

but no lack.

Thank you.

ricco

Get a VIP membership
1278 Posts
Bucklash
4 years ago
0
Level 1

Hi Ricco

Sorry if not understanding but do you mean the dafaultValue?

ie 

$cck->getDefaultValue('some_field');

 
[cat_title] => stdClass Object ( 
 	[id] => 313 
 	[title] => Category Title 
 	[name] => cat_title 
 	[folder] => 11 
 	[type] => text 
 	[description] => 
 	[published] => 1 
 	[label] => Title 
 	[selectlabel] => 
 	[display] => 3 
 	[required] => 
 	[validation] => 
 	[defaultvalue] => <<<<<<<--------------------------------------------
 	[options] => 
 	[options2] => 
 	[minlength] => 0 
 	[maxlength] => 255 
 	[size] => 32 
 	[cols] => 0 
 	[rows] => 0 
 	[ordering] => 1 
 	[sorting] => 0 
 	[divider] => 
 	[bool] => 0 
 	[location] => 
 	[extended] => 
 	[style] => 
 	[script] => 
 	[bool2] => 0 
 	[bool3] => 0 
 	[bool4] => 0 
 	[bool5] => 0 
 	[bool6] => 0 
 	[bool7] => 0 
 	[bool8] => 0 
 	[css] => 
 	[attributes] => 
 	[storage] => standard 
 	[storage_cck] => 
 	[storage_location] => joomla_category 
 	[storage_table] => #__categories 
 	[storage_field] => title 
 	[storage_field2] => 
 	[storage_params] => 
 	[storages] => 
 	[checked_out] => 0 
 	[checked_out_time] => 0000-00-00 00:00:00 
 	[client] => admin 
 	[label2] => 
 	[variation] => 
 	[variation_override] => 
 	[required_alert] => 
 	[validation_options] => 
 	[live] => 
 	[live_options] => 
 	[live_value] => 
 	[markup] => 
 	[markup_class] => 
 	[stage] => 0 
 	[access] => 1 
 	[restriction] => 
 	[restriction_options] => 
 	[computation] => 
 	[computation_options] => 
 	[conditional] => 
 	[conditional_options] => 
 	[position] => mainbody 
 	[value] => 
 	[link] => 
 	[state] => 1 
 	[typo_target] => value 
 	[validate] => Array ( ) 
 	[form] => 
 ) 

310 Posts
ricco
4 years ago
1
Level 1

Hi Bucklash,

No, I'm talking for the Default Value which anyone can enter in Textarea or WYSIWYG Editor fields.

For example in the site form view I created a WYSIWYG Editor field, and in its configuration there is a Default Value button which opens a box where I can enter some text as the default value and it shows in the text area in the front end when rendered. So, my question is how do we enter the value of already existing field together with the text.

Do you understand now?

Best regards,
ricco

4229 Posts
Kadministrator
4 years ago
0
Level 2

HI,

I believe Bucklash has already answered your question, another syntax would be $cck->get('fieldname')->defaultvalue

1278 Posts
Bucklash
4 years ago
0
Level 1

Hi all

I just tried $cck->get('fieldname')->defaultvalue but it doesn't play nice...


I believe it is a javascript thing and that depends upon your editor.


My basic way would be to have a hidden div with textA, another hidden div with textB, and then use the wysiwygs magic like

$('#wysiwyg).val(textA + textB);


Or something like that 


set-textarea-value-with-javascript-after-tinymce-initializing

310 Posts
ricco
4 years ago
2
Level 1

Hi,

Guys you are not understanding me.

I don't want to get the default value of a field. I need to get the value of a field as the default value for a text area or WYSIWYG editor.

For example, lets say I have a text field which has a value of 555. I need to pre populate the text area field with the value of the text field - 555. We can enter static text in the textarea field by setting the Default Value option of the teaxtarea field, but I need the text to be dynamic.

Thank you,

ricco

1278 Posts
Bucklash
4 years ago
1
Level 2

Hi Ricco

I do hijack posts but I do so sincerely... but I tried this a while ago and I don't think there can be a Seblod way.

 - Have the values in the dom somewhere, hidden, and then use javascript and the wysiwyg's api to grab those values and apply in appropriate way.

Pretty much the process in that link I referenced...

Bucklash

310 Posts
ricco
4 years ago
0
Level 3

OK, thank you Bucklash, I will try again, although I think there should be a way to do this with SEBLOD, may be with a code before render field.

4229 Posts
Kadministrator
4 years ago
1
Level 1

Seems I misunderstood your question :) You can solve this by using conditionals, put isFilledBy conditional on text area with isFilled condition. Another way would be to us SD live field, but that field is no longer maintained (currently you just need to change one class name to make it work, search this forum for details).

310 Posts
ricco
4 years ago
0
Level 2

OK, thank you. I will try.

Get a Book for SEBLOD