cmultifileupload model doesnt work when integrating with other model - yii

CMultifileupload working with
<?php echo CHtml::submitButton('Create',array('name'=>'Files')); ?>
as well it $_POST the data to the controller and saves to db
but then if i use
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
dosent Post any data to the controller
I did tried
$_FILES['Files']
no any change
suppose cmultifileupload is modelA and the other mdoelB
I need to integrate both these model's
modelB has submit as
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
due which m unable to integrate so the thing is i need both the models in one form and modelB's id to be the Foreign key to modelA to all the images
HOw do i achieve so? Is it possible? please let me know this for the first time am using cmultiuploadfile am working since past a week but then could not figure out whats wrong Please let me know how can i resolve this

You have to add array('name'=>'Files') to your function call:
echo CHtml::submitButton(
($model->isNewRecord ? 'Create' : 'Save'),
array('name'=>'Files')
);

Related

Dropdownlist with Add and Remove function

I am using the code below display multiple selected values for users to choose from.
<div class="row">
<?php echo $form->labelEx($model,'site_staff'); ?>
<?php //echo $form->textField($model,'site_staff',array('size'=>60,'maxlength'=>255)); ?>
<?php //echo $form->dropDownList($model,'site_staff', CHtml::listData(Biodata::model()->findAll(), 'full_name', 'full_name'), array('empty'=>'Select')); ?>
<?php echo $form->dropDownList($model,'site_staff',CHtml::listData(Biodata::model()->findAll(),'full_name','full_name'),array('multiple'=>'true','prompt'=>'select ','selected'=>'selected'));?>
<?php echo $form->error($model,'site_staff'); ?>
</div>
I am trying to achieve the following but have no idea how to go about:
1) Add and remove function
- When a user choose one or more, by clicking "Add", will display the selected value in another dropdown list
- User can also remove any selected data in the latter dropdown list
So far, the single dropdown works well but users need to use CTRL-CLICK to select more than one option which is not a feasible way of selecting.
Any help is greatly appreciated.
Hii you can also use a multiselect dropdown for this.
Use yii select2 for this.
this is nice extension Please read more about this from here
http://www.yiiframework.com/extension/select2/

Yii2 - active form set empty value on update

I am trying to make update password functionality, but at the moment when I use active record to create form, password field is populated with user password. How can I omit this? This is the code used for generating password field (rest of the form is standard active form template):
<?php echo $form->field($model, 'password')->passwordInput() ?>
Try this..
<?php echo $form->field($model, 'password')->passwordInput(['value'=>'']) ?>

buddypress get activity title

i am trying to get activity title for each activity by using the following code. but it is repeating the activity title for each activity .
<h2 class="posttitle">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ); ?>
<?php the_title_attribute(); ?>"><?php the_title(); ?>
</a></h2>
i Also tried using calling bp_get_activities_title() but it gives no result can some one help me out with this
i believe that is because the_title() just prints out the title. try using the following in order to get the title.
<?php echo get_the_title(bp-activity->$ID); ?>
Sorry for late answer, but how and/or why would activities have a title? You could possibly get the text of the activity itself and use this as the "title" with
echo $activities_template->activity->content;
Perhaps there is another variable in there you might find useful. I suggest printing the array
print_r($activities_template->activity);
and see what's in it.
EDIT: Though you better pray there is no HTML in ->content (or you can just strip the html out :] )

CHtml::link - how to add a html class?

On docs we can read:
public static string link(string $text, mixed $url='#', array $htmlOptions=array ( ))
Question:
I don't understand what $htmlOptions means here. I don't understand how to pass from this representation to a real code.
Can anyone please provide an example about how can we generate a link with a class defined.
Something like:
link hello
It's easier than you might think, although Yii's documentation is perhaps a bit more convoluted than needs to be. However, it does say that $htmlOptions is
additional HTML attributes. Besides normal HTML attributes, a few
special attributes are also recognized (see clientChange and tag for
more details.)
In essence, whatever key/value pairs you put into the array will come out as HTML attributes¹. So, what you want to do is
CHtml::link('link hello', '#', array('class' => 'hello'));
¹except the "special" values that the docs refer to, which will not end up rendered in HTML as-is but either modify the way link works slightly, or end up affecting the HTML in other ways.
<?php echo CHtml::link('Link Text',array('controller/action','param1'=>'value1'), array('target'=>'_blank','class'=>'hello'); ?>
It will be shown as below.
<!--if you disabled url manager in "protected/config/main.php" the output will be -->
<a target="_blank" class="hello" href="index.php?r=controller/action&param1=value1">Link Text</a>
<!--if you enabled url manager in "protected/config/main.php" the output will be -->
<a target="_blank" class="hello" href="controller/action/param1/value1">Link Text</a>
To get a detailed description about CHtml in yii Check this link.
<?php echo CHtml::link("Label Text" , array("/controller_here/action_here") , array('class' => 'class_here')); ?>
or
<?php echo CHtml::link("Label Text" , Yii::app()->createUrl("/controller_here/action_here") , array('class' => 'class_here')); ?>

Drupal - Print content in node template if tagged with certain taxonomy term?

I want some content to only be printed in my node-type.tpl.php if the node has a certain taxonomy term.
With the following I can print the term's name if its ID is 5:
<?php print $node->taxonomy[5]->name ?>
Can I modify the code so it only prints something if the term ID is 5? I tried the following but it doesn't work:
<?php if ($node->taxonomy == '5'): ?>
Print something here if the term ID is 5.
<?php endif; ?>
Im a bit of a newbie with advanced theming so I was hoping to not have to mess about with my template.php.
It seems more complicated than necessary but could the code from here be altered:
Drupal - display blocks according to node's taxonomy term ID
Thanks
Got it working:
<?php if ($node->taxonomy[5]): ?>
print stuff here
<?php endif; ?>