I have observed that when I execute the function:
Yii::$app->request->sendFile() within a row with a gridView, instead of launching the file, it shows it embedded in the HTML.
Then if I remove the Pjax::begin() and Pjax::end() borders that enclose the GridView, Then download works.
How can I work with both functionalities without losing one of them?
This was discussed at Yii2 the solution for now is to use this method:
<?php Pjax::begin([
'id' => 'list',
'linkSelector' => '#list a:not([data-pjax=0])'
]); ?>
custom js or simple link to your action with download
pjax link
<?php Pjax::end(); ?>
It looks like this feature may be included in future releases.
Related
I'm trying to figure out how I can change a single file uploader to a multiple file uploaded for one page and be able to handle the validation of those assets accordingly. With the following code below I am receiving this error. The only thing is its not so much a property as just the array that I need to loop over in my controller.
Getting unknown property: app\models\ModelName::REPORTS
https://www.yiiframework.com/doc/guide/2.0/en/input-file-upload
On this page I have changed my field to the following and need to figure out what to do for the rules.
<?php echo $form->field($model, 'REPORTS[]')->fileInput(['multiple' => true, 'class'=>'button'])->label('Report(s)'); ?>
[['REPORTS'], 'file'],
Is it possible to put js file after active form assets, when the file added via registerJsFile?
I have this code, but the file will be added after yii.js, but before yii.activeForm.js, and I can't find the right call at the moment:
$this->registerJsFile('#web/js/address.js', [
'depends' => [\yii\web\YiiAsset::className()]
]);
It is yii\widgets\ActiveFormAsset which you need to add the dependency to.
You need to add the dependency in the following way
$this->registerJsFile('js/buy-now.js', [
'depends' => [yii\widgets\ActiveFormAsset::className()],
]);
you can always check the source code for any specific widget class to see the name of the assets file that it is using inside the registerClientScript().
See ActiveForm
source
I am trying to print a variable from the .gs code within an HTML document using
<?= var ?>
I know I have done this before, but when I do it now, the entire tag is just rendered - so the page displays
<?= var ?>
rather than do anything with GAS.
Yea, that checks out. You CAN use the .createTemplateFromFile with viewport, and must use .createTemplateFromFile not .createTemplateFromFile with any scripting.
Simple enough, just don't use it often enough to keep it all straight.
My server is built with the yii2 Advanced framework.
I have integrated the Braintree Drop-In form.
The documentation says an invisible payment_method_nonce is created. My question is how should I send this to the server?
On clicking the default submit button in the Drop-In form (filled with one of the test card details) it accepts the info (UI changes with new Change payment method button) but the Post call never happens/doesn't reach the server.
How do I send the payment_method_nonce to the server?
Am I missing something here?
Thanks in advance.
I finally got it to work.
This is the yii2 view code I used:
<?php $form = ActiveForm::begin(); ?>
<div id="payment-form"></div>
<?= Html::submitButton('Submit',['class'=>'btn btn-success']); ?>
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
<script>
var clientToken ='<?php echo $var ;?>';
braintree.setup(clientToken, "dropin", {
container: "payment-form"
});
</script>
Basic stuff with just the drop-in div
I am not familiar with PHP Syntax. Now i added JSON Plugin to my wordpress website and activate it.
When i open url to get_recent_post , it's fine. JSON data are showing.
But when i open get_post , it's only showing
{"status":"error","error":"Include 'id' or 'slug' var in your request."}
So i don't know how to add post id to that URL.
here is the pic. Another get_page , gate_date_posts, etc... links are same showing error.
How can i do it?
To display a post's ID, simply use the following PHP code within the WordPress loop:
<?php the_ID(); ?>
To return the ID, use the following PHP code within the WordPress loop:
<?php get_the_ID; ?>
To get a post's id outside of the WordPress loop use the following PHP code:
<?php global $post; $post->ID ?>
Hope that helps you.
http://yoursite.com/api/get_posts/
with the s
If you use the WordPress link and click on it, you will be fine.