Loading


Advertisement:

Author Topic: photo is required field  (Read 5907 times)

hudson

  • Newbie
  • *
  • Posts: 10
photo is required field
« on: March 27, 2013, 01:45:30 am »
How can i do what choise photo in item-post.php was required field

elite1290

  • Jr. Member
  • **
  • Posts: 59
Re: photo is required field
« Reply #1 on: April 17, 2013, 10:37:07 pm »
yes I want to find out also, anyone knows how to make upload photo a required field?

Bettalegend

  • Full Member
  • ***
  • Posts: 105
Re: photo is required field
« Reply #2 on: April 18, 2013, 12:12:03 am »
devi modificare il file tem.form.class.php che si trova in oc-includes/osclass/frm/Item.form.class.php e cercare la riga

Code: [Select]
<?php if(osc_images_enabled_at_items()) { ?>
                "photos[]": {
                    accept: "<?php echo osc_allowed_extension(); ?>"
                },

e sostituirla così:

Code: [Select]
<?php if(osc_images_enabled_at_items()) { ?>
                "photos[]": {
required: true,
                    accept: "<?php echo osc_allowed_extension(); ?>"
                },

------------------------------------------------------------------------------------------------

you have to edit the file that is located in oc-includes/osclass/frm/Item.form.class.php and look for the line

Code: [Select]
<?php if(osc_images_enabled_at_items()) { ?>
                "photos[]": {
                    accept: "<?php echo osc_allowed_extension(); ?>"
                },

and replace as follows:

Code: [Select]
<?php if(osc_images_enabled_at_items()) { ?>
                "photos[]": {
required: true,
                    accept: "<?php echo osc_allowed_extension(); ?>"
                },

AdsGig

  • Jr. Member
  • **
  • Posts: 72
Re: photo is required field
« Reply #3 on: August 31, 2013, 02:55:43 pm »
This validation works for new ads, but if I edit an existing ad with pictures it is still validating. 
How can we resolved this?

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
Re: photo is required field
« Reply #4 on: August 31, 2013, 05:30:48 pm »
This validation works for new ads, but if I edit an existing ad with pictures it is still validating. 
How can we resolved this?

Copy function that contain that javascript at item.form.class. then use modified class for new post and unmodified for edited post.

AdsGig

  • Jr. Member
  • **
  • Posts: 72
Re: photo is required field
« Reply #5 on: September 01, 2013, 11:15:13 am »
This validation works for new ads, but if I edit an existing ad with pictures it is still validating. 
How can we resolved this?

Copy function that contain that javascript at item.form.class. then use modified class for new post and unmodified for edited post.

Thanks @byteGator for the response I was thinking the same but how to implement it? :)

AdsGig

  • Jr. Member
  • **
  • Posts: 72
Re: photo is required field
« Reply #6 on: October 12, 2013, 09:11:21 am »
seems to be an old topic but how to solve this ?

shamim_biplob

  • Full Member
  • ***
  • Posts: 169
Re: photo is required field
« Reply #7 on: October 13, 2013, 01:42:26 am »
how can i add server side validation? not only for photo but also if i add any field?
i am adding rules in itemAction.php but i dont kno why it is not working. client side working well.

elite1290

  • Jr. Member
  • **
  • Posts: 59
Re: photo is required field
« Reply #8 on: December 08, 2013, 11:39:05 pm »
seems to be an old topic but how to solve this ?

anyone has solution on how to implement for edit ad?

elite1290

  • Jr. Member
  • **
  • Posts: 59
Re: photo is required field
« Reply #9 on: December 10, 2013, 11:15:07 am »
there are 2x file post-item.php and edit-item.php in the theme folder,

and post-item reference
to oc-includes/osclass/frm/Item.form.class.php (say photojava script1)

and edit-item reference
to oc-includes/osclass/frm/Item.form.class.php (say photojava script2) <- has copy and paste

now question is what should be the code for photojava script1 and photojava script2?

photojava script1 we leave it original
photojava script2 what should be the modified code? so that when user edit ad it will not validate
the photojava script2 to check photo as required field, anyone has any clue please advice?

kokobaibaicom

  • Newbie
  • *
  • Posts: 21
Re: photo is required field
« Reply #10 on: February 03, 2014, 10:57:25 pm »
can anyone clarify this? thanks a bunch!

MB Themes

  • Hero Member
  • *****
  • Posts: 4073
  • Frosticek here :)
Re: photo is required field
« Reply #11 on: February 04, 2014, 03:10:06 pm »
@kokobaibaicom
You do not need to bumb 3 same topics  ;)

Use our Image Required Plugin:
https://mb-themes.com/osclass-plugins/30-osclass-image-required-plugin.html
« Last Edit: April 21, 2017, 05:47:36 pm by MB Themes »

kokobaibaicom

  • Newbie
  • *
  • Posts: 21
Re: photo is required field
« Reply #12 on: February 05, 2014, 08:31:23 pm »
i am dying for a solution to this image required. I'm sorry if its a bother

shatadon

  • Newbie
  • *
  • Posts: 1
Re: photo is required field
« Reply #13 on: January 15, 2017, 05:19:55 am »
I've used some Jquery to solve this issue. Where the image is required on new post but not required on edit post.

Currently using V3.7.1 Bender theme

Edit file: /oc-content/themes/bender/item-post.php

LOOK FOR:
Code: [Select]
<?php if( osc_images_enabled_at_items() ) {
        
ItemForm::ajax_photos();
?>


AND ADD RIGHT AFTER:
Code: [Select]
<script type="text/javascript">
    $(document).ready(function(){
$(".qq-upload-button input[name='qqfile']").attr("required", "required");
<?php if(Params::getParam('action') == 'item_edit') { ?>
$(".qq-upload-button input[name='qqfile']").removeAttr("required");         
<?php ?>    
    });
</script>

SO RESULT SHOULD LOOK LIKE:
Code: [Select]
<?php if( osc_images_enabled_at_items() ) {
        
ItemForm::ajax_photos();
?>

<script type="text/javascript">
    $(document).ready(function(){
$(".qq-upload-button input[name='qqfile']").attr("required", "required");
<?php if(Params::getParam('action') == 'item_edit') { ?>
$(".qq-upload-button input[name='qqfile']").removeAttr("required");         
<?php ?>    
    });
</script>

PLEASE NOTE THAT IF YOU ARE USING ANOTHER THEME, THE REFERENCE .qq-upload-button input[name='qqfile'] MAY BE DIFFERENT

WE WILL ALSO NEED TO ADD THIS CODE FOR IOS SUPPORT (place in either header.php or footer.php)
Code: [Select]
<script>
$(document).ready(function() {
    if(isAppleDevice() === true) {
    $("body.item.item-post button[type='submit']").on('click', function(event) {          
if($("ul.qq-upload-list li").length === 0) {     
event.preventDefault();
alert("Opps, it seems you forgot to upload some pictures!");
$('body').animate({
scrollTop: $("input[name='qqfile']").offset().top
}, 500);
$(".qq-upload-button").attr("style","border: 6px solid #ffad00;");
}   
    });
    }
 });
 
function isAppleDevice(){
    return (
        (navigator.userAgent.toLowerCase().indexOf("ipad") > -1) ||
        (navigator.userAgent.toLowerCase().indexOf("iphone") > -1) ||
        (navigator.userAgent.toLowerCase().indexOf("ipod") > -1)
    );
}

</script>

AGAIN THE ELEMENTS I TARGET IN THE CODE ABOVE MAY VARY BASED ON TEMPLATE.
« Last Edit: January 16, 2017, 06:10:10 am by shatadon »

sha_bd

  • Newbie
  • *
  • Posts: 15
Re: photo is required field
« Reply #14 on: April 07, 2017, 01:29:39 pm »
Hi shatadon,

You method works great! But one thing i like to do is...changing the validation message position.

Right now as per your method the image input filed become required but the default error message shows very left of webpage.

How to place the image required field error message at bottom of the image field or very close to image field.

You can see the screenshot for better understanding..

Thanks